119 lines
8.2 KiB
HTML
119 lines
8.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 COBOL applications that use SQL" />
|
|
<meta name="abstract" content="SQL statements can be coded in COBOL program sections as in this table." />
|
|
<meta name="description" content="SQL statements can be coded in COBOL program sections as in this table." />
|
|
<meta name="DC.subject" content="embedded SQL, COBOL, examples, COBOL, UPDATE statement" />
|
|
<meta name="keywords" content="embedded SQL, COBOL, examples, COBOL, UPDATE statement" />
|
|
<meta name="DC.Relation" scheme="URI" content="rzajpcob.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="rzajpcommentscobol.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="rzajpcontinuationcobol.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="rzajpincludecodecobol.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="rzajpmarginscobol.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="rzajpsequencecobol.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="rzajpconamco.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="rzajpcompilecobol.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="rzajpstmtlabelscobol.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="rzajpwhenevercobol.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="rzajpmultisourcecobol.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="rzajpembedsqlcobol" />
|
|
<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 COBOL applications that use SQL</title>
|
|
</head>
|
|
<body id="rzajpembedsqlcobol"><a name="rzajpembedsqlcobol"><!-- --></a>
|
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
|
<h1 class="topictitle1">Embed SQL statements in COBOL applications that use SQL</h1>
|
|
<div><p>SQL statements can be coded in COBOL program sections as in this
|
|
table.</p>
|
|
|
|
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" width="100%" frame="void" border="1" rules="rows"><thead align="left"><tr><th align="left" valign="bottom" width="40.44526901669759%" id="d0e27">SQL Statement</th>
|
|
<th align="left" valign="bottom" width="59.554730983302406%" id="d0e29">Program Section</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr><td align="left" valign="top" width="40.44526901669759%" headers="d0e27 "> <p>BEGIN DECLARE SECTION<br />
|
|
</p>
|
|
<p>END DECLARE SECTION</p>
|
|
<p>DECLARE VARIABLE</p>
|
|
<p>DECLARE STATEMENT</p>
|
|
|
|
</td>
|
|
<td align="left" valign="top" width="59.554730983302406%" headers="d0e29 ">WORKING-STORAGE SECTION or LINKAGE SECTION</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="40.44526901669759%" headers="d0e27 "> <p>INCLUDE SQLCA</p>
|
|
<p>INCLUDE SQLDA</p>
|
|
</td>
|
|
<td align="left" valign="top" width="59.554730983302406%" headers="d0e29 ">WORKING-STORAGE SECTION or LINKAGE SECTION</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="40.44526901669759%" headers="d0e27 ">INCLUDE member-name</td>
|
|
<td align="left" valign="top" width="59.554730983302406%" headers="d0e29 ">DATA DIVISION or PROCEDURE DIVISION</td>
|
|
</tr>
|
|
<tr><td align="left" valign="top" width="40.44526901669759%" headers="d0e27 ">Other</td>
|
|
<td align="left" valign="top" width="59.554730983302406%" headers="d0e29 ">PROCEDURE DIVISION</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<div class="section"><p>Each SQL statement in a COBOL program must begin with EXEC SQL
|
|
and end with END-EXEC. If the SQL statement appears between two COBOL statements,
|
|
the period is optional and might not be appropriate. The EXEC SQL keywords
|
|
must appear all on one line, but the remainder of the statement can appear
|
|
on the next and subsequent lines.</p>
|
|
</div>
|
|
<div class="section"><h4 class="sectiontitle"><em>Example</em></h4><p>An UPDATE statement coded in a COBOL
|
|
program might be coded as follows: </p>
|
|
<pre> EXEC SQL
|
|
<strong>UPDATE</strong> DEPARTMENT
|
|
<strong>SET</strong> MGRNO = :MGR-NUM
|
|
<strong>WHERE</strong> DEPTNO = :INT-DEPT
|
|
END-EXEC.</pre>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<ul class="ullinks">
|
|
<li class="ulchildlink"><strong><a href="rzajpcommentscobol.htm">Comments in COBOL applications that use SQL</a></strong><br />
|
|
In addition to SQL comments (--), you can include COBOL comment lines (* or / in column 7) within embedded SQL statements except between the keywords EXEC and SQL. COBOL debugging lines (D in column 7) are treated as comment lines by the precompiler.</li>
|
|
<li class="ulchildlink"><strong><a href="rzajpcontinuationcobol.htm">Continuation for SQL statements in COBOL applications that use SQL</a></strong><br />
|
|
The line continuation rules for SQL statements are the same as those for other COBOL statements, except that EXEC SQL must be specified within one line.</li>
|
|
<li class="ulchildlink"><strong><a href="rzajpincludecodecobol.htm">Include code in COBOL applications that use SQL</a></strong><br />
|
|
<span>SQL statements or COBOL host variable
|
|
declaration statements can be included by embedding the following SQL statement
|
|
in the source code where the statements are to be embedded.</span></li>
|
|
<li class="ulchildlink"><strong><a href="rzajpmarginscobol.htm">Margins in COBOL applications that use SQL</a></strong><br />
|
|
Code SQL statements in columns 12 through 72. If EXEC SQL starts before the specified margin (that is, before column 12), the SQL precompiler will not recognize the statement.</li>
|
|
<li class="ulchildlink"><strong><a href="rzajpsequencecobol.htm">Sequence numbers in COBOL applications that use SQL</a></strong><br />
|
|
The source statements generated by the SQL precompiler are generated with the same sequence number as the SQL statement.</li>
|
|
<li class="ulchildlink"><strong><a href="rzajpconamco.htm">Names in COBOL applications that use SQL</a></strong><br />
|
|
Any valid COBOL variable name can be used for a host variable and is subject to the following restrictions:</li>
|
|
<li class="ulchildlink"><strong><a href="rzajpcompilecobol.htm">COBOL compile-time options in COBOL applications that use SQL</a></strong><br />
|
|
The COBOL PROCESS statement can be used to specify the compile-time options for the COBOL compiler.</li>
|
|
<li class="ulchildlink"><strong><a href="rzajpstmtlabelscobol.htm">Statement labels in COBOL applications that use SQL</a></strong><br />
|
|
Executable SQL statements in the PROCEDURE DIVISION can be preceded by a paragraph name.</li>
|
|
<li class="ulchildlink"><strong><a href="rzajpwhenevercobol.htm">WHENEVER Statement in COBOL applications that use SQL</a></strong><br />
|
|
The target for the GOTO clause in an SQL WHENEVER statement must be a section name or unqualified paragraph name in the PROCEDURE DIVISION.</li>
|
|
<li class="ulchildlink"><strong><a href="rzajpmultisourcecobol.htm">Multiple source COBOL programs and the SQL COBOL precompiler</a></strong><br />
|
|
The SQL COBOL precompiler does not support precompiling multiple source programs separated with the PROCESS statement.</li>
|
|
</ul>
|
|
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="rzajpcob.htm" title="This topic describes the unique application and coding requirements for embedding SQL statements in a COBOL program. Requirements for host structures and host variables are defined.">Code SQL statements in COBOL applications</a></div>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html> |