90 lines
4.9 KiB
HTML
90 lines
4.9 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="Example: Run CL commands that use SQL stored procedures and ODBC" />
|
|
<meta name="abstract" content="Stored procedure support provides a means to run iSeries server Control Language (CL) commands by using the SQL CALL statement." />
|
|
<meta name="description" content="Stored procedure support provides a means to run iSeries server Control Language (CL) commands by using the SQL CALL statement." />
|
|
<meta name="DC.Relation" scheme="URI" content="rzaikspex.htm" />
|
|
<meta name="DC.Relation" scheme="URI" content="rzaikodbcapifunctions.htm" />
|
|
<meta name="copyright" content="(C) Copyright IBM Corporation 1999, 2006" />
|
|
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 1999, 2006" />
|
|
<meta name="DC.Format" content="XHTML" />
|
|
<meta name="DC.Identifier" content="runclcmd" />
|
|
<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>Example: Run CL commands that use SQL stored procedures and ODBC</title>
|
|
</head>
|
|
<body id="runclcmd"><a name="runclcmd"><!-- --></a>
|
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
|
<h1 class="topictitle1">Example: Run CL commands that use SQL stored procedures and ODBC</h1>
|
|
<div><p>Stored procedure support provides a means to run iSeries™ server
|
|
Control Language (CL) commands by using the SQL CALL statement. </p>
|
|
<div class="section"><div class="p">Use CL commands when:<ul><li>Performing an override for files</li>
|
|
<li>Initiating debug</li>
|
|
<li>Using other commands that can affect the performance of subsequent SQL
|
|
statements</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<div class="section"><p>The following examples show cases where a CL command is run on
|
|
the iSeries server
|
|
by using the CALL statement, which calls the program that processes CL commands.
|
|
That program (QCMDEXC in library QSYS) expects two parameters:</p>
|
|
</div>
|
|
<div class="section"> <ol><li>A string that contains the command text to execute</li>
|
|
<li>A decimal (15,5) field that contains the length of the command text</li>
|
|
</ol>
|
|
</div>
|
|
<div class="section"><p>The parameters must include these attributes for the command to
|
|
be interpreted properly. The second parameter on the CALL statement must have
|
|
characters explicitly specified for all places of the decimal (15,5) field.</p>
|
|
</div>
|
|
<div class="section"><p>In the following example, a C program on the PC is going to run
|
|
an <span class="cmdname">OVRDBF</span> command that is 65 characters long (including
|
|
embedded blanks). The text of the <span class="cmdname">OVRDBF</span> command is as
|
|
follows: </p>
|
|
<pre> OVRDBF FILE(TESTER) TOFILE(JMBLIB/TESTER) MBR(NO2) OVRSCOPE(*JOB)</pre>
|
|
</div>
|
|
<div class="section"><p>The code for performing this command by using ODBC APIs is as
|
|
follows: </p>
|
|
<pre> HSTMT hstmt;
|
|
SQLCHAR stmt[301];
|
|
|
|
rc = SQLAllocHandle(SQL_HANDLE_STMT, hdbc, &hstmt);
|
|
strcpy(stmt,"CALL QSYS.QCMDEXC('OVRDBF FILE(TESTER) TOFILE(MYLIB/");
|
|
strcat(stmt,"TESTER) MBR(NO2) OVRSCOPE(*JOB)',0000000064.00000)");
|
|
rc = SQLExecDirect(hstmt, stmt, SQL_NTS);
|
|
</pre>
|
|
</div>
|
|
<div class="section"><p>Statements now run against file MYLIB/TESTER will reference member
|
|
number 2 rather than the first member.</p>
|
|
</div>
|
|
<div class="section"><p>Another CL command that is useful to run against a database server
|
|
job is the <span class="cmdname">STRDBG</span> command. You do not have to call a stored
|
|
procedure to run this command, though. There is an option on the Diagnostic
|
|
tab of the DSN setup GUI on the Diagnostic tab that will automatically run
|
|
the <span class="cmdname">STRDBG</span> command during the connection attempt. </p>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="rzaikspex.htm" title="View examples of stored procedures.">Examples: Stored procedures</a></div>
|
|
</div>
|
|
<div class="relconcepts"><strong>Related concepts</strong><br />
|
|
<div><a href="rzaikodbcapifunctions.htm" title="Learn about implementations issues when using ODBC APIs.">Implementation issues of ODBC APIs</a></div>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html> |