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

106 lines
7.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="Embed SQL statements in ILE RPG applications that use SQL" />
<meta name="abstract" content="SQL statements coded in an ILE RPG program must be placed in the calculation section." />
<meta name="description" content="SQL statements coded in an ILE RPG program must be placed in the calculation section." />
<meta name="DC.subject" content="embedded SQL, ILE RPG" />
<meta name="keywords" content="embedded SQL, ILE RPG" />
<meta name="DC.Relation" scheme="URI" content="rzajprpgi.htm" />
<meta name="DC.Relation" scheme="URI" content="rzajpcommentsirpg.htm" />
<meta name="DC.Relation" scheme="URI" content="rzajpcontinuationirpg.htm" />
<meta name="DC.Relation" scheme="URI" content="rzajpincludecodeirpg.htm" />
<meta name="DC.Relation" scheme="URI" content="rzajpdirectivesirpg.htm" />
<meta name="DC.Relation" scheme="URI" content="rzajpsequenceirpg.htm" />
<meta name="DC.Relation" scheme="URI" content="rzajprpiamco.htm" />
<meta name="DC.Relation" scheme="URI" content="rzajpstmtlabelsirpg.htm" />
<meta name="DC.Relation" scheme="URI" content="rzajpwheneverirpg.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="rzajpembedirpg" />
<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 ILE RPG applications that use
SQL</title>
</head>
<body id="rzajpembedirpg"><a name="rzajpembedirpg"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Embed SQL statements in ILE RPG applications that use
SQL</h1>
<div><p>SQL statements coded in an ILE RPG program must be placed in the
calculation section. </p>
<div class="section"><p>This requires that a C be placed in position 6. SQL statements
can be placed in detail calculations, in total calculations, or in a RPG subroutines.
The SQL statements are run based on the logic of the RPG statements.</p>
</div>
<div class="section"><p>Both uppercase and lowercase letters are acceptable in SQL statements.</p>
</div>
<div class="section"><h4 class="sectiontitle">Fixed-form RPG</h4><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 80.</p>
</div>
<div class="section"><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 80 must be blank.</p>
</div>
<div class="section"><p>An UPDATE statement coded in an ILE RPG program might be coded
as follows: </p>
<pre>C/EXEC SQL <strong>UPDATE</strong> DEPARTMENT
C+ <strong>SET</strong> MANAGER = :MGRNUM
C+ <strong>WHERE</strong> DEPTNO = :INTDEP
C/END-EXEC</pre>
</div>
<div class="section"><img src="./delta.gif" alt="Start of change" /><h4 class="sectiontitle">Free-form RPG</h4><p>Each SQL statement
must begin with EXEC SQL and end with a semicolon (;). The EXEC SQL keywords
must be on one line. The remaining part of the SQL statement can be on more
than one line.</p>
<p>Example: An UPDATE statement coded in free form might
be coded in the following way:</p>
<pre>EXEC SQL <strong>UPDATE</strong> DEPARTMENT
<strong>SET</strong> MGRNO = :MGR_NUM
<strong>WHERE</strong> DEPTNO = :INT_DEP;</pre>
<img src="./deltaend.gif" alt="End of change" /></div>
</div>
<div>
<ul class="ullinks">
<li class="ulchildlink"><strong><a href="rzajpcommentsirpg.htm">Comments in ILE RPG applications that use SQL</a></strong><br />
In addition to SQL comments (--), ILE RPG comments can be included within SQL statements wherever SQL allows a blank character.</li>
<li class="ulchildlink"><strong><a href="rzajpcontinuationirpg.htm">Continuation for SQL statements in ILE RPG applications that use SQL</a></strong><br />
<span><img src="./delta.gif" alt="Start of change" />This topic introduces the continuation for
SQL statements in two types of RPG format.<img src="./deltaend.gif" alt="End of change" /></span></li>
<li class="ulchildlink"><strong><a href="rzajpincludecodeirpg.htm">Include code in ILE RPG applications that use SQL</a></strong><br />
SQL statements and RPG specifications can be included by using the following SQL statement.</li>
<li class="ulchildlink"><strong><a href="rzajpdirectivesirpg.htm">Use directives in ILE RPG applications that use SQL</a></strong><br />
RPG directives are handled by the SQL precompiler according to the value of the RPG preprocessor options parameter (RPGPPOPT). If the RPG preprocessor is used, the SQL precompile will run using the expanded preprocessed source.</li>
<li class="ulchildlink"><strong><a href="rzajpsequenceirpg.htm">Sequence numbers in ILE RPG 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">CRTSQLRPGI</span> command. </li>
<li class="ulchildlink"><strong><a href="rzajprpiamco.htm">Names in ILE RPG applications that use SQL</a></strong><br />
Any valid ILE RPG variable name can be used for a host variable with the following restrictions.</li>
<li class="ulchildlink"><strong><a href="rzajpstmtlabelsirpg.htm">Statement labels in ILE RPG 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="rzajpwheneverirpg.htm">WHENEVER statement in ILE RPG 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="rzajprpgi.htm" title="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.">Code SQL statements in ILE RPG applications</a></div>
</div>
</div>
</body>
</html>