93 lines
6.2 KiB
HTML
93 lines
6.2 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="Use ILE C compiler external file descriptions in C and C++ applications that use SQL" />
|
||
|
<meta name="abstract" content="You can use the C or C++ #pragma mapinc directive with the #include directive to include external file descriptions in your program." />
|
||
|
<meta name="description" content="You can use the C or C++ #pragma mapinc directive with the #include directive to include external file descriptions in your program." />
|
||
|
<meta name="DC.subject" content="file description, external, C, C++, external file description, host variable, C program, host variable, externally described, #pragma mapinc directive, C++ program, external file description, externally described, #pragma mapinc directive" />
|
||
|
<meta name="keywords" content="file description, external, C, C++, external file description, host variable, C program, host variable, externally described, #pragma mapinc directive, C++ program, external file description, externally described, #pragma mapinc directive" />
|
||
|
<meta name="DC.Relation" scheme="URI" content="rzajpc.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="rzajpilecc" />
|
||
|
<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>Use ILE C compiler external file descriptions in C and C++ applications
|
||
|
that use SQL</title>
|
||
|
</head>
|
||
|
<body id="rzajpilecc"><a name="rzajpilecc"><!-- --></a>
|
||
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
||
|
<h1 class="topictitle1">Use ILE C compiler external file descriptions in C and C++ applications
|
||
|
that use SQL</h1>
|
||
|
<div><p>You can use the C or C++ #pragma mapinc directive with the #include
|
||
|
directive to include external file descriptions in your program.</p>
|
||
|
<div class="section"><p>When used with SQL, only a particular format of the #pragma mapinc
|
||
|
directive is recognized by the SQL precompiler. If all of the required elements
|
||
|
are not specified, the precompiler ignores the directive and does not generate
|
||
|
host variable structures. The required elements are: </p>
|
||
|
<ul><li>Include name</li>
|
||
|
<li>Externally described file name</li>
|
||
|
<li>Format name or a list of format names</li>
|
||
|
<li>Options</li>
|
||
|
<li>Conversion options</li>
|
||
|
</ul>
|
||
|
<p>The library name, union name, conversion options, and prefix name
|
||
|
are optional. Although typedef statements coded by the user are not recognized
|
||
|
by the precompiler, those created by the #pragma mapinc and #include directives
|
||
|
are recognized. SQL supports input, output, both, and key values for the options
|
||
|
parameter. For the conversion options, the supported values are D, p, z, _P,
|
||
|
and 1BYTE_CHAR. These options may be specified in any order except that both
|
||
|
D and p cannot be specified. Unions declared using the typedef union created
|
||
|
by the #pragma mapinc and #include directive cannot be used as host variables
|
||
|
in SQL statements; the members of the unions can be used. Structures that
|
||
|
contain the typedef structure cannot be used in SQL statements; the structure
|
||
|
declared using the typedef can be used.</p>
|
||
|
</div>
|
||
|
<div class="section"><p>To retrieve the definition of the sample table DEPARTMENT described
|
||
|
in <a href="../sqlp/rbafysamptblx.htm"><span class="keyword">DB2<sup>®</sup> UDB for iSeries™</span> sample tables</a> in the DB2 UDB
|
||
|
for <span class="keyword">iSeries</span> SQL Programming
|
||
|
topic collection, you can code the following: </p>
|
||
|
<pre> #pragma mapinc ("dept","CORPDATA/DEPARTMENT(*ALL)","both")
|
||
|
#include "dept"
|
||
|
CORPDATA_DEPARTMENT_DEPARTMENT_both_t Dept_Structure;</pre>
|
||
|
<p>A
|
||
|
host structure named Dept_Structure is defined with the following elements:
|
||
|
DEPTNO, DEPTNAME, MGRNO, and ADMRDEPT. These field names can be used as host
|
||
|
variables in SQL statements.</p>
|
||
|
<div class="note"><span class="notetitle">Note:</span> DATE, TIME, and TIMESTAMP columns generate
|
||
|
character host variable definitions. They are treated by SQL with the same
|
||
|
comparison and assignment rules as a DATE, TIME, and TIMESTAMP column. For
|
||
|
example, a date host variable can only compared against a DATE column or a
|
||
|
character string which is a valid representation of a date. <p>If the GRAPHIC
|
||
|
or VARGRAPHIC column has a UCS-2 CCSID, the generated host variable will have
|
||
|
the UCS-2 CCSID assigned to it. If the GRAPHIC or VARGRAPHIC column has a
|
||
|
UTF-16 CCSID, the generated host variable will have the UTF-16 CCSID assigned
|
||
|
to it.</p>
|
||
|
<p>Although zoned, binary (with non-zero scale fields), and optionally
|
||
|
decimal are mapped to character fields in ILE C for <span class="keyword">iSeries</span>,
|
||
|
SQL will treat these fields as numeric. By using the extended program model
|
||
|
(EPM) routines, you can manipulate these fields to convert zoned and packed
|
||
|
decimal data. For more information, see the <a href="../books/sc092418.pdf " target="_blank">ILE C for iSeries Language Reference</a><img src="wbpdf.gif" alt="Link to PDF" /> topic.</p>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div>
|
||
|
<div class="familylinks">
|
||
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="rzajpc.htm" title="This topic describes the unique application and coding requirements for embedding SQL statements in a C or C++ program.">Code SQL statements in C and C++ applications</a></div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</body>
|
||
|
</html>
|