ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzajp_5.4.0.1/rzajpequivsqlcobol.htm

298 lines
20 KiB
HTML

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-us" xml:lang="en-us">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="security" content="public" />
<meta name="Robots" content="index,follow" />
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
<meta name="DC.Type" content="reference" />
<meta name="DC.Title" content="Determine equivalent SQL and COBOL data types" />
<meta name="abstract" content="The precompiler determines the base SQLTYPE and SQLLEN of host variables based on this table. If a host variable appears with an indicator variable, the SQLTYPE is the base SQLTYPE plus one." />
<meta name="description" content="The precompiler determines the base SQLTYPE and SQLLEN of host variables based on this table. If a host variable appears with an indicator variable, the SQLTYPE is the base SQLTYPE plus one." />
<meta name="DC.subject" content="COBOL program, SQL data types, determining equivalent COBOL, data type, determining equivalent, COBOL, SQL data types, determining equivalent" />
<meta name="keywords" content="COBOL program, SQL data types, determining equivalent COBOL, data type, determining equivalent, COBOL, SQL data types, determining equivalent" />
<meta name="DC.Relation" scheme="URI" content="rzajpcob.htm" />
<meta name="DC.Relation" scheme="URI" content="rzajpnotescobol.htm" />
<meta name="copyright" content="(C) Copyright IBM Corporation 1998, 2006" />
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 1998, 2006" />
<meta name="DC.Format" content="XHTML" />
<meta name="DC.Identifier" content="rzajpequivsqlcobol" />
<meta name="DC.Language" content="en-us" />
<!-- All rights reserved. Licensed Materials Property of IBM -->
<!-- US Government Users Restricted Rights -->
<!-- Use, duplication or disclosure restricted by -->
<!-- GSA ADP Schedule Contract with IBM Corp. -->
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
<link rel="stylesheet" type="text/css" href="./ic.css" />
<title>Determine equivalent SQL and COBOL data types</title>
</head>
<body id="rzajpequivsqlcobol"><a name="rzajpequivsqlcobol"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Determine equivalent SQL and COBOL data types</h1>
<div><p>The precompiler determines the base SQLTYPE and SQLLEN of host
variables based on this table. If a host variable appears with an indicator
variable, the SQLTYPE is the base SQLTYPE plus one.</p>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" width="100%" frame="hsides" border="1" rules="all"><caption>Table 1. COBOL declarations mapped to typical
SQL data types</caption><thead align="left"><tr><th align="left" valign="bottom" width="35.38175046554935%" id="d0e41">COBOL data type</th>
<th align="left" valign="bottom" width="21.601489757914337%" id="d0e43">SQLTYPE of host variable</th>
<th align="left" valign="bottom" width="21.415270018621975%" id="d0e45">SQLLEN of host variable</th>
<th align="left" valign="bottom" width="21.601489757914337%" id="d0e47">SQL data type</th>
</tr>
</thead>
<tbody><tr><td align="left" valign="top" width="35.38175046554935%" headers="d0e41 ">S9(i)V9(d) COMP-3 or S9(i)V9(d) COMP or S9(i)V9(d)
PACKED-DECIMAL</td>
<td align="left" valign="top" width="21.601489757914337%" headers="d0e43 ">484</td>
<td align="left" valign="top" width="21.415270018621975%" headers="d0e45 ">i+d in byte 1, d in byte 2</td>
<td align="left" valign="top" width="21.601489757914337%" headers="d0e47 ">DECIMAL(i+d,d)</td>
</tr>
<tr><td align="left" valign="top" width="35.38175046554935%" headers="d0e41 ">S9(i)V9(d) DISPLAY SIGN LEADING SEPARATE</td>
<td align="left" valign="top" width="21.601489757914337%" headers="d0e43 ">504</td>
<td align="left" valign="top" width="21.415270018621975%" headers="d0e45 ">i+d in byte 1, d in byte 2</td>
<td align="left" valign="top" width="21.601489757914337%" headers="d0e47 ">No exact equivalent use DECIMAL(i+d,d) or
NUMERIC (i+d,d)</td>
</tr>
<tr><td align="left" valign="top" width="35.38175046554935%" headers="d0e41 ">S9(i)V9(d)DISPLAY</td>
<td align="left" valign="top" width="21.601489757914337%" headers="d0e43 ">488</td>
<td align="left" valign="top" width="21.415270018621975%" headers="d0e45 ">i+d in byte 1, d in byte 2</td>
<td align="left" valign="top" width="21.601489757914337%" headers="d0e47 ">NUMERIC(i+d,d)</td>
</tr>
<tr><td align="left" valign="top" width="35.38175046554935%" headers="d0e41 ">S9(i) BINARY or S9(i) COMP-4 where i is from
1 to 4</td>
<td align="left" valign="top" width="21.601489757914337%" headers="d0e43 ">500</td>
<td align="left" valign="top" width="21.415270018621975%" headers="d0e45 ">2</td>
<td align="left" valign="top" width="21.601489757914337%" headers="d0e47 ">SMALLINT</td>
</tr>
<tr><td align="left" valign="top" width="35.38175046554935%" headers="d0e41 ">S9(i) BINARY or S9(i) COMP-4 where i is from
5 to 9</td>
<td align="left" valign="top" width="21.601489757914337%" headers="d0e43 ">496</td>
<td align="left" valign="top" width="21.415270018621975%" headers="d0e45 ">4</td>
<td align="left" valign="top" width="21.601489757914337%" headers="d0e47 ">INTEGER</td>
</tr>
<tr><td align="left" valign="top" width="35.38175046554935%" headers="d0e41 ">S9(i) BINARY or S9(i) COMP-4 where i is from
10 to 18. <p></p>
Not supported for COBOL for <span class="keyword">iSeries™</span>.</td>
<td align="left" valign="top" width="21.601489757914337%" headers="d0e43 ">492</td>
<td align="left" valign="top" width="21.415270018621975%" headers="d0e45 ">8</td>
<td align="left" valign="top" width="21.601489757914337%" headers="d0e47 ">BIGINT</td>
</tr>
<tr><td align="left" valign="top" width="35.38175046554935%" headers="d0e41 ">S9(i)V9(d) BINARY or S9(i)V9(d) COMP-4 where
i+d ≤ 4</td>
<td align="left" valign="top" width="21.601489757914337%" headers="d0e43 ">500</td>
<td align="left" valign="top" width="21.415270018621975%" headers="d0e45 ">i+d in byte 1, d in byte 2</td>
<td align="left" valign="top" width="21.601489757914337%" headers="d0e47 ">No exact equivalent use DECIMAL(i+d,d) or
NUMERIC (i+d,d)</td>
</tr>
<tr><td align="left" valign="top" width="35.38175046554935%" headers="d0e41 ">S9(i)V9(d) BINARY or S9(i)V9(d) COMP-4 where
4 &lt; i+d ≤ 9</td>
<td align="left" valign="top" width="21.601489757914337%" headers="d0e43 ">496</td>
<td align="left" valign="top" width="21.415270018621975%" headers="d0e45 ">i+d in byte 1, d in byte 2</td>
<td align="left" valign="top" width="21.601489757914337%" headers="d0e47 ">No exact equivalent use DECIMAL(i+d,d) or
NUMERIC (i+d,d)</td>
</tr>
<tr><td align="left" valign="top" width="35.38175046554935%" headers="d0e41 ">COMP-1 <p></p>
Not supported for COBOL
for <span class="keyword">iSeries</span>.</td>
<td align="left" valign="top" width="21.601489757914337%" headers="d0e43 ">480</td>
<td align="left" valign="top" width="21.415270018621975%" headers="d0e45 ">4</td>
<td align="left" valign="top" width="21.601489757914337%" headers="d0e47 ">FLOAT(single precision)</td>
</tr>
<tr><td align="left" valign="top" width="35.38175046554935%" headers="d0e41 ">COMP-2 <p></p>
Not supported for COBOL
for <span class="keyword">iSeries</span>.</td>
<td align="left" valign="top" width="21.601489757914337%" headers="d0e43 ">480</td>
<td align="left" valign="top" width="21.415270018621975%" headers="d0e45 ">8</td>
<td align="left" valign="top" width="21.601489757914337%" headers="d0e47 ">FLOAT(double precision)</td>
</tr>
<tr><td align="left" valign="top" width="35.38175046554935%" headers="d0e41 ">Fixed-length character data</td>
<td align="left" valign="top" width="21.601489757914337%" headers="d0e43 ">452</td>
<td align="left" valign="top" width="21.415270018621975%" headers="d0e45 ">m</td>
<td align="left" valign="top" width="21.601489757914337%" headers="d0e47 ">CHAR(m)</td>
</tr>
<tr><td align="left" valign="top" width="35.38175046554935%" headers="d0e41 ">Varying-length character data</td>
<td align="left" valign="top" width="21.601489757914337%" headers="d0e43 ">448</td>
<td align="left" valign="top" width="21.415270018621975%" headers="d0e45 ">m</td>
<td align="left" valign="top" width="21.601489757914337%" headers="d0e47 ">VARCHAR(m)</td>
</tr>
<tr><td align="left" valign="top" width="35.38175046554935%" headers="d0e41 ">Fixed-length graphic data <p></p>
Not
supported for COBOL for <span class="keyword">iSeries</span>.</td>
<td align="left" valign="top" width="21.601489757914337%" headers="d0e43 ">468</td>
<td align="left" valign="top" width="21.415270018621975%" headers="d0e45 ">m</td>
<td align="left" valign="top" width="21.601489757914337%" headers="d0e47 ">GRAPHIC(m)</td>
</tr>
<tr><td align="left" valign="top" width="35.38175046554935%" headers="d0e41 ">Varying-length graphic data <p></p>
Not
supported for COBOL for <span class="keyword">iSeries</span>.</td>
<td align="left" valign="top" width="21.601489757914337%" headers="d0e43 ">464</td>
<td align="left" valign="top" width="21.415270018621975%" headers="d0e45 ">m</td>
<td align="left" valign="top" width="21.601489757914337%" headers="d0e47 ">VARGRAPHIC(m)</td>
</tr>
<tr><td align="left" valign="top" width="35.38175046554935%" headers="d0e41 ">DATE <p></p>
Not supported for COBOL
for <span class="keyword">iSeries</span>.</td>
<td align="left" valign="top" width="21.601489757914337%" headers="d0e43 ">384</td>
<td align="left" valign="top" width="21.415270018621975%" headers="d0e45 ">&nbsp;</td>
<td align="left" valign="top" width="21.601489757914337%" headers="d0e47 ">DATE</td>
</tr>
<tr><td align="left" valign="top" width="35.38175046554935%" headers="d0e41 ">TIME <p></p>
Not supported for COBOL
for <span class="keyword">iSeries</span>.</td>
<td align="left" valign="top" width="21.601489757914337%" headers="d0e43 ">388</td>
<td align="left" valign="top" width="21.415270018621975%" headers="d0e45 ">&nbsp;</td>
<td align="left" valign="top" width="21.601489757914337%" headers="d0e47 ">TIME</td>
</tr>
<tr><td align="left" valign="top" width="35.38175046554935%" headers="d0e41 ">TIMESTAMP <p></p>
Not supported for
COBOL for <span class="keyword">iSeries</span>.</td>
<td align="left" valign="top" width="21.601489757914337%" headers="d0e43 ">392</td>
<td align="left" valign="top" width="21.415270018621975%" headers="d0e45 ">26</td>
<td align="left" valign="top" width="21.601489757914337%" headers="d0e47 ">TIMESTAMP</td>
</tr>
</tbody>
</table>
</div>
<div class="section"><p>The following table can be used to determine the COBOL data type
that is equivalent to a given SQL data type.</p>
</div>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" width="100%" frame="hsides" border="1" rules="all"><caption>Table 2. SQL data types mapped to typical
COBOL declarations</caption><thead align="left"><tr><th align="left" valign="bottom" width="29.236499068901306%" id="d0e261">SQL data type</th>
<th align="left" valign="bottom" width="35.940409683426445%" id="d0e263">COBOL data type</th>
<th align="left" valign="bottom" width="34.82309124767225%" id="d0e265">Notes</th>
</tr>
</thead>
<tbody><tr><td align="left" valign="top" width="29.236499068901306%" headers="d0e261 ">SMALLINT</td>
<td align="left" valign="top" width="35.940409683426445%" headers="d0e263 ">S9(m) COMP-4</td>
<td align="left" valign="top" width="34.82309124767225%" headers="d0e265 ">m is from 1 to 4</td>
</tr>
<tr><td align="left" valign="top" width="29.236499068901306%" headers="d0e261 ">INTEGER</td>
<td align="left" valign="top" width="35.940409683426445%" headers="d0e263 ">S9(m) COMP-4</td>
<td align="left" valign="top" width="34.82309124767225%" headers="d0e265 ">m is from 5 to 9</td>
</tr>
<tr><td align="left" valign="top" width="29.236499068901306%" headers="d0e261 ">BIGINT</td>
<td align="left" valign="top" width="35.940409683426445%" headers="d0e263 ">S9(m) COMP-4 for ILE COBOL for <span class="keyword">iSeries</span>. <p></p>
Not
supported for COBOL for <span class="keyword">iSeries</span>.</td>
<td align="left" valign="top" width="34.82309124767225%" headers="d0e265 ">m is from 10 to 18</td>
</tr>
<tr><td align="left" valign="top" width="29.236499068901306%" headers="d0e261 ">DECIMAL(p,s)</td>
<td align="left" valign="top" width="35.940409683426445%" headers="d0e263 ">If p&lt;64: S9(p-s)V9(s) PACKED-DECIMAL or
S9(p-s)V9(s) COMP or S9(p-s)V9(s) COMP-3 If p&gt;63: Not supported</td>
<td align="left" valign="top" width="34.82309124767225%" headers="d0e265 "><em>p</em> is precision; <em>s</em> is scale.
0&lt;=s&lt;=p&lt;=63. If s=0, use S9(p) or S9(p)V. If s=p, use SV9(s).</td>
</tr>
<tr><td align="left" valign="top" width="29.236499068901306%" headers="d0e261 ">NUMERIC(p,s)</td>
<td align="left" valign="top" width="35.940409683426445%" headers="d0e263 ">If p&lt;19: S9(p-s)V9(s) DISPLAY If p&gt;18:
Not supported</td>
<td align="left" valign="top" width="34.82309124767225%" headers="d0e265 "><em>p</em> is precision; <em>s</em> is scale.
0&lt;=s&lt;=p&lt;=18. If s=0, use S9(p) or S9(p)V. If s=p, use SV9(s).</td>
</tr>
<tr><td align="left" valign="top" width="29.236499068901306%" headers="d0e261 ">FLOAT(single precision)</td>
<td align="left" valign="top" width="35.940409683426445%" headers="d0e263 ">COMP-1 for ILE COBOL for <span class="keyword">iSeries</span>. <p></p>
Not
supported for COBOL for <span class="keyword">iSeries</span>.</td>
<td align="left" valign="top" width="34.82309124767225%" headers="d0e265 ">&nbsp;</td>
</tr>
<tr><td align="left" valign="top" width="29.236499068901306%" headers="d0e261 ">FLOAT(double precision)</td>
<td align="left" valign="top" width="35.940409683426445%" headers="d0e263 ">COMP-2 for ILE COBOL for <span class="keyword">iSeries</span>. <p></p>
Not
supported for COBOL for <span class="keyword">iSeries</span>.</td>
<td align="left" valign="top" width="34.82309124767225%" headers="d0e265 ">&nbsp;</td>
</tr>
<tr><td align="left" valign="top" width="29.236499068901306%" headers="d0e261 ">CHAR(n)</td>
<td align="left" valign="top" width="35.940409683426445%" headers="d0e263 ">Fixed-length character string</td>
<td align="left" valign="top" width="34.82309124767225%" headers="d0e265 ">32766≥n≥1</td>
</tr>
<tr><td align="left" valign="top" width="29.236499068901306%" headers="d0e261 ">VARCHAR(n)</td>
<td align="left" valign="top" width="35.940409683426445%" headers="d0e263 ">Varying-length character string</td>
<td align="left" valign="top" width="34.82309124767225%" headers="d0e265 ">32740≥n≥1</td>
</tr>
<tr><td align="left" valign="top" width="29.236499068901306%" headers="d0e261 ">CLOB</td>
<td align="left" valign="top" width="35.940409683426445%" headers="d0e263 ">None</td>
<td align="left" valign="top" width="34.82309124767225%" headers="d0e265 ">Use SQL TYPE IS to declare a CLOB for ILE
COBOL for <span class="keyword">iSeries</span>. <p></p>
Not
supported for COBOL for <span class="keyword">iSeries</span>.</td>
</tr>
<tr><td align="left" valign="top" width="29.236499068901306%" headers="d0e261 ">GRAPHIC(n)</td>
<td align="left" valign="top" width="35.940409683426445%" headers="d0e263 ">Fixed-length graphic string for ILE COBOL
for <span class="keyword">iSeries</span>. <p></p>
Not
supported for COBOL for <span class="keyword">iSeries</span>.</td>
<td align="left" valign="top" width="34.82309124767225%" headers="d0e265 ">16383≥n≥1</td>
</tr>
<tr><td align="left" valign="top" width="29.236499068901306%" headers="d0e261 ">VARGRAPHIC(n)</td>
<td align="left" valign="top" width="35.940409683426445%" headers="d0e263 ">Varying-length graphic string for ILE COBOL
for <span class="keyword">iSeries</span>. <p></p>
Not
supported for COBOL for <span class="keyword">iSeries</span>.</td>
<td align="left" valign="top" width="34.82309124767225%" headers="d0e265 ">16370≥n≥1</td>
</tr>
<tr><td align="left" valign="top" width="29.236499068901306%" headers="d0e261 ">DBCLOB</td>
<td align="left" valign="top" width="35.940409683426445%" headers="d0e263 ">None</td>
<td align="left" valign="top" width="34.82309124767225%" headers="d0e265 ">Use SQL TYPE IS to declare a DBCLOB for ILE
COBOL for <span class="keyword">iSeries</span>. <p></p>
</td>
</tr>
<tr><td align="left" valign="top" width="29.236499068901306%" headers="d0e261 ">BINARY</td>
<td align="left" valign="top" width="35.940409683426445%" headers="d0e263 ">None</td>
<td align="left" valign="top" width="34.82309124767225%" headers="d0e265 ">Use SQL TYPE IS to declare a BINARY. <p></p>
</td>
</tr>
<tr><td align="left" valign="top" width="29.236499068901306%" headers="d0e261 ">VARBINARY</td>
<td align="left" valign="top" width="35.940409683426445%" headers="d0e263 ">None</td>
<td align="left" valign="top" width="34.82309124767225%" headers="d0e265 ">Use SQL TYPE IS to declare a VARBINARY. <p></p>
</td>
</tr>
<tr><td align="left" valign="top" width="29.236499068901306%" headers="d0e261 ">BLOB</td>
<td align="left" valign="top" width="35.940409683426445%" headers="d0e263 ">None</td>
<td align="left" valign="top" width="34.82309124767225%" headers="d0e265 ">Use SQL TYPE IS to declare a BLOB. <p></p>
</td>
</tr>
<tr><td align="left" valign="top" width="29.236499068901306%" headers="d0e261 ">DATE</td>
<td align="left" valign="top" width="35.940409683426445%" headers="d0e263 ">Fixed-length character string or DATE for
ILE COBOL for <span class="keyword">iSeries</span>.</td>
<td align="left" valign="top" width="34.82309124767225%" headers="d0e265 ">If the format is *USA, *JIS, *EUR, or *ISO,
allow at least 10 characters. If the format is *YMD, *DMY, or *MDY, allow
at least 8 characters. If the format is *JUL, allow at least 6 characters.</td>
</tr>
<tr><td align="left" valign="top" width="29.236499068901306%" headers="d0e261 ">TIME</td>
<td align="left" valign="top" width="35.940409683426445%" headers="d0e263 ">Fixed-length character string or TIME for
ILE COBOL for <span class="keyword">iSeries</span>.</td>
<td align="left" valign="top" width="34.82309124767225%" headers="d0e265 ">Allow at least 6 characters; 8 to include
seconds.</td>
</tr>
<tr><td align="left" valign="top" width="29.236499068901306%" headers="d0e261 ">TIMESTAMP</td>
<td align="left" valign="top" width="35.940409683426445%" headers="d0e263 ">Fixed-length character string or TIMESTAMP
for ILE COBOL for <span class="keyword">iSeries</span>.</td>
<td align="left" valign="top" width="34.82309124767225%" headers="d0e265 ">n must be at least 19. To include microseconds
at full precision, n must be 26. If n is less than 26, truncation occurs on
the microseconds part.</td>
</tr>
<tr><td align="left" valign="top" width="29.236499068901306%" headers="d0e261 ">DATALINK</td>
<td align="left" valign="top" width="35.940409683426445%" headers="d0e263 ">Not supported</td>
<td valign="top" width="34.82309124767225%" headers="d0e265 ">&nbsp;</td>
</tr>
<tr><td valign="top" width="29.236499068901306%" headers="d0e261 ">ROWID</td>
<td valign="top" width="35.940409683426445%" headers="d0e263 ">None</td>
<td valign="top" width="34.82309124767225%" headers="d0e265 ">Use SQL TYPE IS to declare a ROWID.</td>
</tr>
</tbody>
</table>
</div>
</div>
<div>
<ul class="ullinks">
<li class="ulchildlink"><strong><a href="rzajpnotescobol.htm">Notes on COBOL variable declaration and usage</a></strong><br />
Any level 77 data description entry can be followed by one or more REDEFINES entries. However, the names in these entries cannot be used in SQL statements.</li>
</ul>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="rzajpcob.htm" title="This topic describes the unique application and coding requirements for embedding SQL statements in a COBOL program. Requirements for host structures and host variables are defined.">Code SQL statements in COBOL applications</a></div>
</div>
</div>
</body>
</html>