105 lines
4.9 KiB
HTML
105 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="Use embedded CALL statement with an SQLDA" />
|
|
<meta name="abstract" content="In either type of embedded CALL (where a procedure definition may or may not exist), an SQLDA may be passed rather than a parameter list." />
|
|
<meta name="description" content="In either type of embedded CALL (where a procedure definition may or may not exist), an SQLDA may be passed rather than a parameter list." />
|
|
<meta name="DC.subject" content="stored procedures, embedded CALL, with SQLDA, CALL statement, stored procedure, with SQLDA, statements, CALL, examples, embedded CALL" />
|
|
<meta name="keywords" content="stored procedures, embedded CALL, with SQLDA, CALL statement, stored procedure, with SQLDA, statements, CALL, examples, embedded CALL" />
|
|
<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="rbafycalldrda" />
|
|
<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 embedded CALL statement with an SQLDA</title>
|
|
</head>
|
|
<body id="rbafycalldrda"><a name="rbafycalldrda"><!-- --></a>
|
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
|
<h1 class="topictitle1">Use embedded CALL statement with an SQLDA</h1>
|
|
<div><p>In either type of embedded CALL (where a procedure definition may
|
|
or may not exist), an SQLDA may be passed rather than a parameter list.</p>
|
|
<div class="section"><p>The following C examples illustrates this. Assume that the stored
|
|
procedure is expecting 2 parameters, the first of type SHORT INT and the second
|
|
of type CHAR with a length of 4. </p>
|
|
<div class="note"><span class="notetitle">Note:</span> By using the code examples, you
|
|
agree to the terms of the <a href="codedisclaimer.htm">Code license and disclaimer information</a>.</div>
|
|
<pre>#define SQLDA_HV_ENTRIES 2
|
|
#define SHORTINT 500
|
|
#define NUL_TERM_CHAR 460
|
|
|
|
exec sql include sqlca;
|
|
exec sql include sqlda;
|
|
…
|
|
typedef struct sqlda Sqlda;
|
|
typedef struct sqlda* Sqldap;
|
|
…
|
|
main()
|
|
{
|
|
Sqldap dap;
|
|
short col1;
|
|
char col2[4];
|
|
int bc;
|
|
dap = (Sqldap) malloc(bc=SQLDASIZE(SQLDA_HV_ENTRIES));
|
|
/* SQLDASIZE is a macro defined in the sqlda include */
|
|
col1 = 431;
|
|
strcpy(col2,"abc");
|
|
strncpy(dap->sqldaid,"SQLDA ",8);
|
|
dap->sqldabc = bc; /* bc set in the malloc statement above */
|
|
dap->sqln = SQLDA_HV_ENTRIES;
|
|
dap->sqld = SQLDA_HV_ENTRIES;
|
|
dap->sqlvar[0].sqltype = SHORTINT;
|
|
dap->sqlvar[0].sqllen = 2;
|
|
dap->sqlvar[0].sqldata = (char*) &col1;
|
|
dap->sqlvar[0].sqlname.length = 0;
|
|
dap->sqlvar[1].sqltype = NUL_TERM_CHAR;
|
|
dap->sqlvar[1].sqllen = 4;
|
|
dap->sqlvar[1].sqldata = col2;
|
|
…
|
|
EXEC SQL <strong>CALL</strong> P1 <strong>USING</strong> <strong>DESCRIPTOR</strong> :*dap;
|
|
…
|
|
}</pre>
|
|
</div>
|
|
<div class="section"><p>The name of the called procedure may also be stored in a host
|
|
variable and the host variable used in the CALL statement, instead of the
|
|
hard-coded procedure name. For example: </p>
|
|
<pre>…
|
|
main()
|
|
{
|
|
char proc_name[15];
|
|
…
|
|
strcpy (proc_name, "MYLIB.P3");
|
|
…
|
|
EXEC SQL <strong>CALL</strong> :proc_name ...;
|
|
…
|
|
}</pre>
|
|
</div>
|
|
<div class="section"><p>In the above example, if MYLIB.P3 is expecting parameters, then
|
|
either a parameter list or an SQLDA passed with the USING DESCRIPTOR clause
|
|
may be used, as shown in the previous example.</p>
|
|
</div>
|
|
<div class="section"><p>When a host variable containing the procedure name is used in
|
|
the CALL statement and a CREATE PROCEDURE catalog definition exists, it will
|
|
be used. The procedure name cannot be specified as a parameter marker.</p>
|
|
</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> |