109 lines
8.6 KiB
HTML
109 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 RPG/400 applications" />
|
|
<meta name="abstract" content="The RPG/400 licensed program supports both RPG II and RPG III programs." />
|
|
<meta name="description" content="The RPG/400 licensed program supports both RPG II and RPG III programs." />
|
|
<meta name="DC.subject" content="RPG/400 program, coding SQL statements, RPG/400, application program, coding SQL statements" />
|
|
<meta name="keywords" content="RPG/400 program, coding SQL statements, RPG/400, application program, coding SQL statements" />
|
|
<meta name="DC.Relation" scheme="URI" content="rzajpkickoff.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="rzajpsqlcarpg.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="rzajpsqldarpg.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="rzajpembedsqlrpg.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="rzajphostvariablesrpg.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="rzajphoststrucrpg.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="rzajphostarrayrpg.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="rzajpexternalfilerpg.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="rzajpequivsqlrpg.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="rzajpindicatorrpg.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="rzajprpgparm.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="rzajpendingrpg.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="rzajprpg" />
|
|
<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 RPG/400 applications</title>
|
|
</head>
|
|
<body id="rzajprpg"><a name="rzajprpg"><!-- --></a>
|
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
|
<h1 class="topictitle1">Code SQL statements in RPG/400 applications</h1>
|
|
<div><p>The RPG/400<sup>®</sup> licensed
|
|
program supports both RPG II and RPG III programs.</p>
|
|
<p>SQL statements can only be used in RPG III programs. RPG II and AutoReport
|
|
are NOT supported. All referrals to RPG in this guide apply to RPG III or
|
|
ILE RPG only.</p>
|
|
<p>This topic describes the unique application and coding requirements for
|
|
embedding SQL statements in a RPG/400 program. 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 RPG, see the <em>RPG/400 User's
|
|
Guide</em> and <em>RPG/400 Reference</em> manuals on the <a href="http://publib.boulder.ibm.com/iseries/v5r1/ic2924/rzaqhindex.htm">V5R1
|
|
Supplemental Manuals</a><img src="www.gif" alt="Link outside information center" /> Web site.</p>
|
|
</div>
|
|
<div>
|
|
<ul class="ullinks">
|
|
<li class="ulchildlink"><strong><a href="rzajpsqlcarpg.htm">Define the SQL communications area in RPG/400 applications that use SQL</a></strong><br />
|
|
The SQL precompiler automatically places the SQLCA in the input
|
|
specifications of the RPG/400 program prior to the first calculation specification. </li>
|
|
<li class="ulchildlink"><strong><a href="rzajpsqldarpg.htm">Define SQL descriptor areas in RPG/400 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 topic, only the SQLDA form is discussed.<img src="./deltaend.gif" alt="End of change" /></span></li>
|
|
<li class="ulchildlink"><strong><a href="rzajpembedsqlrpg.htm">Embed SQL statements in RPG/400 applications that use SQL</a></strong><br />
|
|
SQL statements coded in an RPG/400 program must be placed in the
|
|
calculation section. </li>
|
|
<li class="ulchildlink"><strong><a href="rzajphostvariablesrpg.htm">Use host variables in RPG/400 applications that use SQL</a></strong><br />
|
|
All host variables used in SQL statements must be explicitly declared.
|
|
LOB, ROWID, and binary host variables are not supported in RPG/400.</li>
|
|
<li class="ulchildlink"><strong><a href="rzajphoststrucrpg.htm">Use host structures in RPG/400 applications that use SQL</a></strong><br />
|
|
The RPG/400 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="rzajphostarrayrpg.htm">Use host structure arrays in RPG/400 applications that use SQL</a></strong><br />
|
|
A host structure array is defined as an occurrence data structure. An occurrence data structure can be used on the SQL FETCH statement when fetching multiple rows.</li>
|
|
<li class="ulchildlink"><strong><a href="rzajpexternalfilerpg.htm">Use external file descriptions in RPG/400 applications that use SQL</a></strong><br />
|
|
The SQL precompiler processes the RPG/400 source in much the same manner
|
|
as the ILE RPG compiler. This means that the precompiler processes the /COPY
|
|
statement for definitions of host variables.</li>
|
|
<li class="ulchildlink"><strong><a href="rzajpequivsqlrpg.htm">Determine equivalent SQL and RPG/400 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="rzajpindicatorrpg.htm">Use indicator variables in RPG/400 applications that use SQL</a></strong><br />
|
|
An indicator variable is a two-byte integer.</li>
|
|
<li class="ulchildlink"><strong><a href="rzajprpgparm.htm">Differences in RPG/400 because of structure parameter passing techniques</a></strong><br />
|
|
The SQL RPG/400 precompiler attempts to use the structure
|
|
parameter passing technique, if possible.</li>
|
|
<li class="ulchildlink"><strong><a href="rzajpendingrpg.htm">Correctly end a called RPG/400 program that uses SQL</a></strong><br />
|
|
SQL run time builds and maintains data areas (internal SQLDAs) for each SQL statement which contains host variables.</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> |