104 lines
5.3 KiB
HTML
104 lines
5.3 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="concept" />
|
|
<meta name="DC.Title" content="SQL tables" />
|
|
<meta name="abstract" content="SQL supports tables that contain Unicode graphic columns by specifying a Unicode CCSID for the GRAPHIC and VARGRAPHIC data types." />
|
|
<meta name="description" content="SQL supports tables that contain Unicode graphic columns by specifying a Unicode CCSID for the GRAPHIC and VARGRAPHIC data types." />
|
|
<meta name="DC.Relation" scheme="URI" content="rbagsucs2andas400.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="../db2/rbafzmst02.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="rbagsucssqlconsid" />
|
|
<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>SQL tables</title>
|
|
</head>
|
|
<body id="rbagsucssqlconsid"><a name="rbagsucssqlconsid"><!-- --></a>
|
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
|
<h1 class="topictitle1">SQL tables</h1>
|
|
<div><p>SQL supports tables that contain Unicode graphic columns by specifying
|
|
a Unicode CCSID for the GRAPHIC and VARGRAPHIC data types.</p>
|
|
<p>The following SQL example creates the table U_TABLE. U_TABLE contains one
|
|
character column called EMPNO, and two Unicode graphic columns. NAME is a
|
|
fixed-length Unicode graphic column and DESCRIPTION is a variable-length Unicode
|
|
graphic column. The decision was made to use a character field because the
|
|
EMPNO field only contains numerics and Unicode support is not needed. The
|
|
NAME and DESCRIPTION fields are both Unicode fields. Both of these fields
|
|
may contain data from more than one EBCDIC code page.</p>
|
|
<pre>CREATE TABLE U_TABLE (EMPNO CHAR(6) NOT NULL,
|
|
NAME GRAPHIC(30) CCSID 1200,
|
|
DESCRIPTION VARGRAPHIC(500) CCSID 1200)</pre>
|
|
<div class="section" id="rbagsucssqlconsid__Header_191"><a name="rbagsucssqlconsid__Header_191"><!-- --></a><h4 class="sectiontitle">Insert data</h4><p>SBCS character, mixed
|
|
character, and DBCS graphic data can be inserted into Unicode graphic columns
|
|
using the SQL INSERT statement. DB2 Universal Database™ (UDB)
|
|
for iSeries™ SQL
|
|
converts the data to Unicode graphic. In SQL programs, the DECLARE VARIABLE
|
|
statement can be used to attach a Unicode CCSID to graphic host variables.</p>
|
|
<p>The
|
|
following SQL example converts character data to Unicode graphic for the NAME
|
|
and DESCRIPTION columns and inserts the row into the U_TABLE.</p>
|
|
<pre>INSERT INTO U_TABLE VALUES('000001','John Doe','Engineer')</pre>
|
|
</div>
|
|
<div class="section" id="rbagsucssqlconsid__Header_192"><a name="rbagsucssqlconsid__Header_192"><!-- --></a><h4 class="sectiontitle">Select Unicode data</h4><p>Implicit conversion
|
|
of Unicode graphic data is supported on a FETCH or select INTO and CALL.</p>
|
|
<p>In
|
|
the following example, the EMPNO column is returned in empno_hv as character
|
|
data. The NAME column is returned in name_hv as Unicode graphic data because
|
|
name_hv is a Unicode variable. It is not converted to character, mixed character,
|
|
or DBCS graphic.</p>
|
|
<pre>...
|
|
char empno_hv[7];
|
|
wchar_t name_hv[31];
|
|
EXEC SQL DECLARE :name_hv VARIABLE CCSID 13488;
|
|
...
|
|
EXEC SQL SELECT EMPNO, NAME
|
|
INTO :empno_hv, :name_hv
|
|
.FROM U_TABLE;
|
|
...</pre>
|
|
<p>To return Unicode graphic data as EBCDIC data, the prior
|
|
example can be changed to return the Unicode data as character data, EMPNO
|
|
and NAME are returned in the job CCSID.</p>
|
|
<pre>...
|
|
char empno_hv[7];
|
|
char name_hv[31];
|
|
...
|
|
EXEC SQL SELECT EMPNO, NAME
|
|
INTO :empno_hv, :name_hv
|
|
FROM U_TABLE;
|
|
...</pre>
|
|
<p>When doing selection, implicit conversions are done when
|
|
comparing Unicode graphic data and character or DBCS graphic data.</p>
|
|
<p>The
|
|
following example converts the character string 'John Doe' to Unicode graphic
|
|
and then selects the rows where the NAME column is 'John Doe'.</p>
|
|
<pre>EXEC SQL DECLARE C1 CURSOR FOR
|
|
SELECT *
|
|
FROM U_TABLE
|
|
WHERE NAME = 'John Doe';</pre>
|
|
<p>The SQL Reference information
|
|
includes additional information about using SQL with Unicode graphic data.</p>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="rbagsucs2andas400.htm" title="i5/OS provides support for Unicode.">Unicode on i5/OS</a></div>
|
|
</div>
|
|
<div class="relconcepts"><strong>Related concepts</strong><br />
|
|
<div><a href="../db2/rbafzmst02.htm">SQL reference</a></div>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html> |