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

86 lines
6.0 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="Embed SQL statements in RPG/400 applications that use SQL" />
<meta name="abstract" content="SQL statements coded in an RPG/400 program must be placed in the calculation section." />
<meta name="description" content="SQL statements coded in an RPG/400 program must be placed in the calculation section." />
<meta name="DC.subject" content="embedded SQL, RPG/400" />
<meta name="keywords" content="embedded SQL, RPG/400" />
<meta name="DC.Relation" scheme="URI" content="rzajprpg.htm" />
<meta name="DC.Relation" scheme="URI" content="rzajpexampembedsqlrpg.htm" />
<meta name="DC.Relation" scheme="URI" content="rzajpcommentsrpg.htm" />
<meta name="DC.Relation" scheme="URI" content="rzajpcontinuationrpg.htm" />
<meta name="DC.Relation" scheme="URI" content="rzajpincludecoderpg.htm" />
<meta name="DC.Relation" scheme="URI" content="rzajpsequencerpg.htm" />
<meta name="DC.Relation" scheme="URI" content="rzajprpnamco.htm" />
<meta name="DC.Relation" scheme="URI" content="rzajpstmtlabelsrpg.htm" />
<meta name="DC.Relation" scheme="URI" content="rzajpwheneverrpg.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="rzajpembedsqlrpg" />
<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>Embed SQL statements in RPG/400 applications that use SQL</title>
</head>
<body id="rzajpembedsqlrpg"><a name="rzajpembedsqlrpg"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Embed SQL statements in RPG/400 applications that use SQL</h1>
<div><p>SQL statements coded in an RPG/400<sup>®</sup> program must be placed in the
calculation section. </p>
<p>This requires that a C be placed in position 6. SQL statements can be placed
in detail calculations, in total calculations, or in an RPG/400 subroutine.
The SQL statements are run based on the logic of the RPG/400 statements.</p>
<p>The keywords EXEC SQL indicate the beginning of an SQL statement. EXEC
SQL must occupy positions 8 through 16 of the source statement, preceded by
a / in position 7. The SQL statement may start in position 17 and continue
through position 74.</p>
<p>The keyword END-EXEC ends the SQL statement. END-EXEC must occupy positions
8 through 16 of the source statement, preceded by a slash (/) in position
7. Positions 17 through 74 must be blank.</p>
<p>Both uppercase and lowercase letters are acceptable in SQL statements.</p>
</div>
<div>
<ul class="ullinks">
<li class="ulchildlink"><strong><a href="rzajpexampembedsqlrpg.htm">Example: Embed SQL statements in RPG/400 applications that use SQL</a></strong><br />
An UPDATE statement coded in an RPG/400 program might be coded as this
example shows.</li>
<li class="ulchildlink"><strong><a href="rzajpcommentsrpg.htm">Comments in RPG/400 applications that use SQL</a></strong><br />
In addition to SQL comments (--), RPG/400 comments can be included within
SQL statements wherever a blank is allowed, except between the keywords EXEC
and SQL.</li>
<li class="ulchildlink"><strong><a href="rzajpcontinuationrpg.htm">Continuation for SQL statements in RPG/400 applications that use SQL</a></strong><br />
When additional records are needed to contain the SQL statement, positions 9 through 74 can be used. Position 7 must be a + (plus sign), and position 8 must be blank.</li>
<li class="ulchildlink"><strong><a href="rzajpincludecoderpg.htm">Include code in RPG/400 applications that use SQL</a></strong><br />
SQL statements and RPG/400 calculation specifications can
be included by embedding the SQL statement.</li>
<li class="ulchildlink"><strong><a href="rzajpsequencerpg.htm">Sequence numbers in RPG/400 applications that use SQL</a></strong><br />
The sequence numbers of the source statements generated by the
SQL precompiler are based on the *NOSEQSRC/*SEQSRC keywords of the OPTION
parameter on the <span class="cmdname">CRTSQLRPG</span> command.</li>
<li class="ulchildlink"><strong><a href="rzajprpnamco.htm">Names in RPG/400 applications that use SQL</a></strong><br />
Any valid RPG variable name can be used for a host variable and is subject to the following restrictions.</li>
<li class="ulchildlink"><strong><a href="rzajpstmtlabelsrpg.htm">Statement labels in RPG/400 applications that use SQL</a></strong><br />
A TAG statement can precede any SQL statement. Code the TAG statement on the line preceding EXEC SQL.</li>
<li class="ulchildlink"><strong><a href="rzajpwheneverrpg.htm">WHENEVER statement in RPG/400 applications that use SQL</a></strong><br />
The target for the GOTO clause must be the label of the TAG statement. The scope rules for the GOTO/TAG must be observed.</li>
</ul>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="rzajprpg.htm" title="The RPG/400 licensed program supports both RPG II and RPG III programs.">Code SQL statements in RPG/400 applications</a></div>
</div>
</div>
</body>
</html>