70 lines
4.3 KiB
HTML
70 lines
4.3 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="Tips: Run and call iSeries stored procedures" />
|
||
<meta name="abstract" content="Use these tips for running and calling iSeries stored procedures." />
|
||
<meta name="description" content="Use these tips for running and calling iSeries stored procedures." />
|
||
<meta name="DC.Relation" scheme="URI" content="rzaikspex.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="callsp4" />
|
||
<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>Tips: Run and call iSeries stored procedures</title>
|
||
</head>
|
||
<body id="callsp4"><a name="callsp4"><!-- --></a>
|
||
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
||
<h1 class="topictitle1">Tips: Run and call iSeries stored procedures</h1>
|
||
<div><p>Use these tips for running and calling iSeries™ stored procedures.</p>
|
||
<div class="section"><h4 class="sectiontitle">Running a stored procedure on the iSeries server:</h4><p>ODBC provides
|
||
a standard interface for calling stored procedures. The implementation of
|
||
stored procedures differs significantly across various databases. This simple
|
||
example follows the recommended approach for running a stored procedure on
|
||
the iSeries server:</p>
|
||
<ol><li>Set up a <strong>create procedure</strong> statement for the stored procedure and
|
||
create it. The creation of the stored procedure only needs to be done once
|
||
and it does not have to be done through ODBC. The definition that it provides
|
||
is available to all ODBC as well as integrated <span class="keyword">i5/OS™</span> applications. </li>
|
||
<li>Prepare the stored procedure call.</li>
|
||
<li>Bind the parameters of the procedure, indicating whether each parameter
|
||
is to be used for input to the procedure, output from the procedure, or input/output.</li>
|
||
<li>Call the stored procedure.</li>
|
||
</ol>
|
||
</div>
|
||
<div class="section"><h4 class="sectiontitle">Calling iSeries stored procedures using Visual Basic:</h4><p>Use
|
||
care in coding the <strong>SQLBindParameter</strong> functions. Never use Visual Basic
|
||
strings as a buffer when binding either columns (<strong>SQLBindCol</strong>) or parameters
|
||
(<strong>SQLBindParameter</strong>). Instead, use byte arrays, which–unlike strings–will
|
||
not be moved around in memory. See <a href="callsp.htm#callsp">Example: Call an iSeries stored procedure by using Visual Basic</a> for
|
||
more information. </p>
|
||
<p>Pay careful attention to the data types that are
|
||
involved. There may be subtle differences with those that you use with, for
|
||
instance, a select statement. Also, ensure that you have an adequately sized
|
||
buffer for output and input/output parameters. The way that you code the stored
|
||
procedure on the iSeries server
|
||
can affect performance significantly. Whenever possible, avoid closing the
|
||
program with <span class="cmdname">exit()</span> in C language and with <span class="cmdname">SETON
|
||
LR</span> in RPG language. Preferably, use RETRN or return, but you may
|
||
need to re-initialize variables on each call, and by-pass file opens.</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>
|
||
</body>
|
||
</html> |