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

97 lines
8.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="Code SQL statements in C and C++ applications" />
<meta name="abstract" content="This topic describes the unique application and coding requirements for embedding SQL statements in a C or C++ program." />
<meta name="description" content="This topic describes the unique application and coding requirements for embedding SQL statements in a C or C++ program." />
<meta name="DC.subject" content="C program, coding SQL statements, C++ program, application program, C, C++" />
<meta name="keywords" content="C program, coding SQL statements, C++ program, application program, C, C++" />
<meta name="DC.Relation" scheme="URI" content="rzajpkickoff.htm" />
<meta name="DC.Relation" scheme="URI" content="rzajpsqlcac.htm" />
<meta name="DC.Relation" scheme="URI" content="rzajpsqldac.htm" />
<meta name="DC.Relation" scheme="URI" content="rzajpembedsqlc.htm" />
<meta name="DC.Relation" scheme="URI" content="rzajphostsqlc.htm" />
<meta name="DC.Relation" scheme="URI" content="rzajphoststrucc.htm" />
<meta name="DC.Relation" scheme="URI" content="rzajphostarrayc.htm" />
<meta name="DC.Relation" scheme="URI" content="rzajppointerdtc.htm" />
<meta name="DC.Relation" scheme="URI" content="rzajptypedefc.htm" />
<meta name="DC.Relation" scheme="URI" content="rzajpilecc.htm" />
<meta name="DC.Relation" scheme="URI" content="rzajpequivsqlc.htm" />
<meta name="DC.Relation" scheme="URI" content="rzajpindvard.htm" />
<meta name="DC.Relation" scheme="URI" content="rzajpwritesqlapp.htm" />
<meta name="DC.Relation" scheme="URI" content="rzajpsamprog.htm" />
<meta name="DC.Relation" scheme="URI" content="rzajperrorandwarning.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="rzajpc" />
<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>Code SQL statements in C and C++ applications</title>
</head>
<body id="rzajpc"><a name="rzajpc"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Code SQL statements in C and C++ applications</h1>
<div><p>This topic describes the unique application and coding requirements
for embedding SQL statements in a C or C++ program.</p>
<p>C program refers to ILE C for <span class="keyword">iSeries™</span> programs.
C++ program refers to ILE C++ programs. This topic also defines the requirements
for host structures and host variables. For more details, see the following
sections: </p>
<div class="note"><span class="notetitle">Note:</span> By using the code examples, you agree to the terms of the <a href="codedisclaimer.htm">Code license and disclaimer information</a>.</div>
</div>
<div>
<ul class="ullinks">
<li class="ulchildlink"><strong><a href="rzajpsqlcac.htm">Define the SQL communications area in C and C++ applications that use SQL</a></strong><br />
A C or C++ program can be written to use the SQLCA to check return status for embedded SQL statements, or the program can use the SQL diagnostics area to check return status.</li>
<li class="ulchildlink"><strong><a href="rzajpsqldac.htm">Define SQL descriptor areas in C and C++ applications that use SQL</a></strong><br />
<span><img src="./delta.gif" alt="Start of change" />There are two types of SQL descriptor areas.
One is defined with the ALLOCATE DESCRIPTOR statement. The other is defined
using the SQL descriptor area (SQLDA) structure. In this topic, only the SQLDA
form is discussed.<img src="./deltaend.gif" alt="End of change" /></span></li>
<li class="ulchildlink"><strong><a href="rzajpembedsqlc.htm">Embed SQL statements in C and C++ applications that use SQL</a></strong><br />
SQL statements can be coded in a C or C++ program wherever executable statements can appear.</li>
<li class="ulchildlink"><strong><a href="rzajphostsqlc.htm">Use host variables in C and C++ applications that use SQL</a></strong><br />
All host variables used in SQL statements must be explicitly declared prior to their first use.</li>
<li class="ulchildlink"><strong><a href="rzajphoststrucc.htm">Use host structures in C and C++ applications that use SQL</a></strong><br />
In C and C++ programs, you can define a <em>host structure</em>,
which is a named set of elementary C or C++ variables.</li>
<li class="ulchildlink"><strong><a href="rzajphostarrayc.htm">Use arrays of host structures in C and C++ applications that use SQL</a></strong><br />
In C and C++ programs, you can define a host structure array that has the dimension attribute. Host structure arrays have a maximum of two levels, even though the array might occur within a multiple-level structure. Another structure is not needed if a varying-length character string or a varying-length graphic string is not used.</li>
<li class="ulchildlink"><strong><a href="rzajppointerdtc.htm">Use pointer data types in C and C++ applications that use SQL</a></strong><br />
You can also declare host variables that are pointers to the supported C and C++ data types, with the following restrictions.</li>
<li class="ulchildlink"><strong><a href="rzajptypedefc.htm">Use typedef in C and C++ applications that use SQL</a></strong><br />
You can also use the typedef declarations to define your own identifiers that will be used in place of C type specifiers such as short, float, and double.</li>
<li class="ulchildlink"><strong><a href="rzajpilecc.htm">Use ILE C compiler external file descriptions in C and C++ applications that use SQL</a></strong><br />
You can use the C or C++ #pragma mapinc directive with the #include directive to include external file descriptions in your program.</li>
<li class="ulchildlink"><strong><a href="rzajpequivsqlc.htm">Determine equivalent SQL and C or C++ data types</a></strong><br />
The precompiler determines the base SQLTYPE and SQLLEN of host variables based on the following table. If a host variable appears with an indicator variable, the SQLTYPE is the base SQLTYPE plus one.</li>
<li class="ulchildlink"><strong><a href="rzajpindvard.htm">Use indicator variables in C and C++ applications that use SQL</a></strong><br />
An indicator variable is a two-byte integer (short int).</li>
</ul>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="rzajpkickoff.htm" title="This topic collection explains how to create database applications in host languages that use DB2 Universal Database for iSeries SQL statements and functions.">Embedded SQL programming</a></div>
</div>
<div class="relconcepts"><strong>Related concepts</strong><br />
<div><a href="rzajpwritesqlapp.htm" title="You can create database applications in host languages that use DB2 UDB for iSeries SQL statements and functions.">Write applications that use SQL</a></div>
<div><a href="rzajperrorandwarning.htm" title="The conditions described in the following topics could produce an error or warning message during an attempted compile process.">Error and warning messages during a compile of application programs that use SQL</a></div>
</div>
<div class="relref"><strong>Related reference</strong><br />
<div><a href="rzajpsamprog.htm" title="This topic contains a sample application showing how to code SQL statements in each of the languages supported by the DB2 UDB for iSeries system.">Sample programs using DB2 UDB for iSeries statements</a></div>
</div>
</div>
</body>
</html>