ibm-information-center/dist/eclipse/plugins/i5OS.ic.sqlp_5.4.0.1/rbafydynamiccall.htm

75 lines
4.5 KiB
HTML
Raw Permalink Normal View History

2024-04-02 14:02:31 +00:00
<?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="Use dynamic CALL statement where no CREATE PROCEDURE exists" />
<meta name="abstract" content="The following rules pertain to the processing of a dynamic CALL statement when there is no CREATE PROCEDURE definition." />
<meta name="description" content="The following rules pertain to the processing of a dynamic CALL statement when there is no CREATE PROCEDURE definition." />
<meta name="DC.subject" content="stored procedures, dynamic CALL, CALL statement, stored procedure, statements, CALL, dynamic with stored procedure, examples, invoking stored procedures" />
<meta name="keywords" content="stored procedures, dynamic CALL, CALL statement, stored procedure, statements, CALL, dynamic with stored procedure, examples, invoking stored procedures" />
<meta name="DC.Relation" scheme="URI" content="rbafyinvokeproc.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="rbafydynamiccall" />
<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>Use dynamic CALL statement where no CREATE PROCEDURE exists</title>
</head>
<body id="rbafydynamiccall"><a name="rbafydynamiccall"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Use dynamic CALL statement where no CREATE PROCEDURE exists</h1>
<div><p>The following rules pertain to the processing of a dynamic CALL
statement when there is no CREATE PROCEDURE definition.</p>
<div class="section"><ul><li>All arguments are treated as IN type parameters.</li>
<li>The CALL type is GENERAL (no indicator argument is passed).</li>
<li>The program to call is determined based on the procedure name specified
on the CALL and the naming convention.</li>
<li>The language of the program to call is determined based on information
retrieved from the system about the program.</li>
</ul>
</div>
<div class="section"><h4 class="sectiontitle">Example: Dynamic CALL statement where no CREATE PROCEDURE
exists</h4><p>The following is a C example of a dynamic CALL statement:
</p>
<pre> char hv3[10],string[100];
:
strcpy(string,"CALL MYLIB.P3 ('P3 TEST')");
EXEC SQL <strong>EXECUTE IMMEDIATE</strong> :string;
:
</pre>
</div>
<div class="section"><p>This example shows a dynamic CALL statement executed through an
EXECUTE IMMEDIATE statement. The call is made to program MYLIB.P3 with one
parameter passed as a character variable containing 'P3 TEST'.</p>
</div>
<div class="section"><p>When executing a CALL statement and passing a constant, as in
the previous example, the length of the expected argument in the program must
be kept in mind. If program MYLIB.P3 expected an argument of only 5 characters,
the last 2 characters of the constant specified in the example is lost to
the program. </p>
<div class="note"><span class="notetitle">Note:</span> For this reason, it is always safer to use host variables
on the CALL statement so that the attributes of the procedure can be matched
exactly and so that characters are not lost. For dynamic SQL, host variables
can be specified for CALL statement arguments if the PREPARE and EXECUTE statements
are used to process it.</div>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="rbafyinvokeproc.htm" title="The SQL CALL statement calls a stored procedure.">Invoke a stored procedure</a></div>
</div>
</div>
</body>
</html>