ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzaha_5.4.0.1/callproc.htm

106 lines
6.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="concept" />
<meta name="DC.Title" content="Process CallableStatements" />
<meta name="abstract" content="Processing SQL stored procedure calls with a CallableStatement object is accomplished with the same methods that are used with a PreparedStatement object." />
<meta name="description" content="Processing SQL stored procedure calls with a CallableStatement object is accomplished with the same methods that are used with a PreparedStatement object." />
<meta name="DC.Relation" scheme="URI" content="callable.htm" />
<meta name="DC.Relation" scheme="URI" content="callexample1.htm" />
<meta name="DC.Relation" scheme="URI" content="callexample2.htm" />
<meta name="DC.Relation" scheme="URI" content="callexample3.htm" />
<meta name="copyright" content="(C) Copyright IBM Corporation 2006" />
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 2006" />
<meta name="DC.Format" content="XHTML" />
<meta name="DC.Identifier" content="callproc" />
<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>Process CallableStatements</title>
</head>
<body id="callproc"><a name="callproc"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Process CallableStatements</h1>
<div><p>Processing SQL stored procedure calls with a CallableStatement
object is accomplished with the same methods that are used with a PreparedStatement
object.</p>
<div class="section"><h4 class="sectiontitle">Return results for stored procedures</h4><p>If an SQL query
statement is processed within a stored procedure, the query results can be
made available to the program calling the stored procedure. Multiple queries
can also be called within the stored procedure and the calling program can
process all the ResultSets that are available.</p>
<p>See <a href="callexample1.htm">Example:
Create a procedure with multiple ResultSets</a> for more information.</p>
<div class="note"><span class="notetitle">Note:</span> If
a stored procedure is processed with executeQuery and it does not return a
ResultSet, an SQLException is thrown.</div>
</div>
<div class="section"><h4 class="sectiontitle">Access ResultSets concurrently</h4><p>Return results for
stored procedures deals with ResultSets and stored procedures and provides
an example that works with all Java™ Development Kit (JDK) releases. In
the example, the ResultSets are processed in order from the first ResultSet
that the stored procedure opened to the last ResultSet opened. One ResultSet
is closed before the next is used.</p>
<p>In JDK 1.4 and subsequent versions,
there is support for working with ResultSets from stored procedures concurrently.</p>
<div class="note"><span class="notetitle">Note:</span> This
feature was added to the underlying system support through the Command Line
Interface (CLI) in V5R2. As a result, JDK 1.4 or a subsequent version of the
JDK running on a system before V5R2 does not have this support available to
it.</div>
</div>
<div class="section"><h4 class="sectiontitle">Return update counts for stored procedures</h4><p>Returning
update counts for stored procedures is a feature discussed in the JDBC specification,
but it is not currently supported on the iSeries™ platform. There is no way to
return multiple update counts from a stored procedure call. If an update count
is needed from a processed SQL statement within a stored procedure, there
are two ways of returning the value:</p>
<ul><li>Return the value as an output parameter.</li>
<li>Pass back the value as the return value from the parameter. This is a
special case of an output parameter. See Process stored procedures that have
a return for more information.</li>
</ul>
</div>
<div class="section"><h4 class="sectiontitle">Process stored procedures where the expected return is unknown</h4><p>If
the results from a stored procedure call are not known, the execute method
should be used. Once this method has been processed, the JDBC driver can tell
the application what types of results the stored procedure generated through
API calls. The execute method returns true if the result is one or more ResultSets.
Updating counts do not come from stored procedure calls.</p>
</div>
<div class="section"><h4 class="sectiontitle">Process stored procedures that have a return value</h4><p>The iSeries platform
supports stored procedures that have a return value similar to a function's
return value. The return value from a stored procedure is labeled like other
parameters marks and is labeled such that it is assigned by the stored procedure
call. An example of this is as follows:</p>
<blockquote><pre>? = CALL MYPROC(?, ?, ?)</pre>
</blockquote>
<p>The
return value from a stored procedure call is always an integer type and must
be registered like any other output parameter.</p>
<p>See <a href="callexample3.htm">Example:
Create a procedure with return values</a> for more information.</p>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="callable.htm" title="The CallableStatement interface extends PreparedStatement and provides support for output and input/output parameters. The CallableStatement interface also has support for input parameters that is provided by the PreparedStatement interface.">CallableStatements</a></div>
</div>
<div class="relref"><strong>Related reference</strong><br />
<div><a href="callexample1.htm" title="This example shows how to access a database and then create a procedure with multiple ResultSets.">Example: Create a procedure with multiple ResultSets</a></div>
<div><a href="callexample2.htm" title="This example shows how to access a database and then create a procedure with input and output parameters.">Example: Create a procedure with input and output parameters</a></div>
<div><a href="callexample3.htm" title="This example shows how to access a database and then create a procedure with return values.">Example: Create a procedure with return values</a></div>
</div>
</div>
</body>
</html>