96 lines
8.6 KiB
HTML
96 lines
8.6 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 ILE RPG applications" />
|
|
<meta name="abstract" content="This topic describes the unique application and coding requirements for embedding SQL statements in an ILE RPG program. The coding requirements for host variables are defined." />
|
|
<meta name="description" content="This topic describes the unique application and coding requirements for embedding SQL statements in an ILE RPG program. The coding requirements for host variables are defined." />
|
|
<meta name="DC.subject" content="ILE RPG program, coding SQL statements, RPG, RPG program, application program, ILE RPG" />
|
|
<meta name="keywords" content="ILE RPG program, coding SQL statements, RPG, RPG program, application program, ILE RPG" />
|
|
<meta name="DC.Relation" scheme="URI" content="rzajpkickoff.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="rzajpsqlcairpg.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="rzajpsqldairpg.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="rzajpembedirpg.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="rzajphostvariablesirpg.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="rzajphoststrucirpg.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="rzajphostarrayirpg.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="rzajpexternalirpg.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="rzajpequivsqlirpg.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="rzajpindicatorirpg.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="rzajpexampsqldairpg.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="rzajpexampsqlirpg.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="rzajpwritesqlapp.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="rzajpssile.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="rzajprpgi" />
|
|
<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 ILE RPG applications</title>
|
|
</head>
|
|
<body id="rzajprpgi"><a name="rzajprpgi"><!-- --></a>
|
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
|
<h1 class="topictitle1">Code SQL statements in ILE RPG applications</h1>
|
|
<div><p>This topic describes the unique application and coding requirements
|
|
for embedding SQL statements in an ILE RPG program. The coding requirements
|
|
for host variables are defined.</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>
|
|
<p>For more information about programming using ILE RPG, see the <a href="../books/sc092507.pdf " target="_blank">ILE RPG Programmer's Guide</a><img src="wbpdf.gif" alt="Link to PDF" /> topic and the <a href="../books/sc092508.pdf " target="_blank">ILE RPG Reference</a><img src="wbpdf.gif" alt="Link to PDF" /> topic.</p>
|
|
</div>
|
|
<div>
|
|
<ul class="ullinks">
|
|
<li class="ulchildlink"><strong><a href="rzajpsqlcairpg.htm">Define the SQL communications area in ILE RPG applications that use SQL</a></strong><br />
|
|
The SQL precompiler automatically places the SQLCA in the definition specifications of the ILE RPG program prior to the first calculation specification, unless a SET OPTION SQLCA = *NO statement is found.</li>
|
|
<li class="ulchildlink"><strong><a href="rzajpsqldairpg.htm">Define SQL descriptor areas in ILE RPG 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 SQLDA structure. In this section, only the SQLDA form is discussed.<img src="./deltaend.gif" alt="End of change" /></span></li>
|
|
<li class="ulchildlink"><strong><a href="rzajpembedirpg.htm">Embed SQL statements in ILE RPG applications that use SQL</a></strong><br />
|
|
SQL statements coded in an ILE RPG program must be placed in the calculation section.</li>
|
|
<li class="ulchildlink"><strong><a href="rzajphostvariablesirpg.htm">Use host variables in ILE RPG applications that use SQL</a></strong><br />
|
|
All host variables used in SQL statements must be explicitly declared.</li>
|
|
<li class="ulchildlink"><strong><a href="rzajphoststrucirpg.htm">Use host structures in ILE RPG applications that use SQL</a></strong><br />
|
|
The ILE RPG data structure name can be used as a <strong>host
|
|
structure</strong> name if subfields exist in the data structure. The use of the
|
|
data structure name in an SQL statement implies the list of subfield names
|
|
making up the data structure.</li>
|
|
<li class="ulchildlink"><strong><a href="rzajphostarrayirpg.htm">Use host structure arrays in ILE RPG applications that use SQL</a></strong><br />
|
|
A host structure array is defined as an occurrence data structure or a data structure with the keyword DIM coded. Both types of data structures can be used on the SQL FETCH or INSERT statement when processing multiple rows.</li>
|
|
<li class="ulchildlink"><strong><a href="rzajpexternalirpg.htm">Use external file descriptions in ILE RPG applications that use SQL</a></strong><br />
|
|
Field definitions for externally described files, including renaming of fields, are recognized by the SQL precompiler. The external definition form of the data structure can be used to obtain a copy of the column names to be used as host variables.</li>
|
|
<li class="ulchildlink"><strong><a href="rzajpequivsqlirpg.htm">Determine equivalent SQL and ILE RPG data types</a></strong><br />
|
|
The precompiler determines the base SQLTYPE and SQLLEN of host variables according to 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="rzajpindicatorirpg.htm">Use indicator variables in ILE RPG applications that use SQL</a></strong><br />
|
|
An indicator variable is a binary field with length less than 5 (2 bytes).</li>
|
|
<li class="ulchildlink"><strong><a href="rzajpexampsqldairpg.htm">Example of the SQLDA for a multiple row-area fetch in ILE RPG applications that use SQL</a></strong><br />
|
|
The following is an example of the SQLDA for a multiple row-area fetch in ILE RPG.</li>
|
|
<li class="ulchildlink"><strong><a href="rzajpexampsqlirpg.htm">Example of dynamic SQL in an ILE RPG application that uses SQL</a></strong><br />
|
|
The following is an example of using dynamic SQL in ILE RPG.</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="rzajpssile.htm" title="This sample program is written in the ILE RPG programming language.">Example: SQL statements in ILE RPG programs</a></div>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html> |