ibm-information-center/dist/eclipse/plugins/i5OS.ic.cli_5.4.0.1/rzadpfnprcs.htm

294 lines
18 KiB
HTML
Raw 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="SQLProcedures - Get list of procedure names" />
<meta name="DC.Relation" scheme="URI" content="rzadphdapi.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="rzadpfnprcs" />
<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>SQLProcedures</title>
</head>
<body id="rzadpfnprcs"><a name="rzadpfnprcs"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">SQLProcedures - Get list of procedure names</h1>
<div><div class="section"><h4 class="sectiontitle">Purpose</h4> <p><samp class="codeph">SQLProcedures()</samp> returns
a list of procedure names that have been registered at the server, and which
match the specified search pattern.</p>
<p> The information is returned in
an SQL result set, which can be retrieved using the same functions that are
used to process a result set that is generated by a query.</p>
</div>
<div class="section"><h4 class="sectiontitle">Syntax</h4><pre>SQLRETURN SQLProcedures (SQLHSTMT StatementHandle,
SQLCHAR *CatalogName,
SQLSMALLINT NameLength1,
SQLCHAR *SchemaName,
SQLSMALLINT NameLength2,
SQLCHAR *ProcName,
SQLSMALLINT NameLength3);</pre>
</div>
<div class="section"><h4 class="sectiontitle">Function arguments</h4>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" width="100%" frame="hsides" border="1" rules="all"><caption>Table 1. SQLProcedures arguments</caption><thead align="left"><tr><th align="left" valign="bottom" width="17.59259259259259%" id="d0e49">Data type</th>
<th align="left" valign="bottom" width="23.51851851851852%" id="d0e51">Argument </th>
<th align="left" valign="bottom" width="11.851851851851853%" id="d0e53">Use </th>
<th align="left" valign="bottom" width="47.03703703703704%" id="d0e55">Description </th>
</tr>
</thead>
<tbody><tr><td align="left" valign="top" width="17.59259259259259%" headers="d0e49 ">SQLCHAR *</td>
<td align="left" valign="top" width="23.51851851851852%" headers="d0e51 "><em>CatalogName</em> </td>
<td align="left" valign="top" width="11.851851851851853%" headers="d0e53 ">Input</td>
<td align="left" valign="top" width="47.03703703703704%" headers="d0e55 ">Catalog qualifier of a 3 part procedure name.
<p>This must be a NULL pointer or a zero length string.</p>
</td>
</tr>
<tr><td align="left" valign="top" width="17.59259259259259%" headers="d0e49 ">SQLCHAR *</td>
<td align="left" valign="top" width="23.51851851851852%" headers="d0e51 "><em>ProcName</em> </td>
<td align="left" valign="top" width="11.851851851851853%" headers="d0e53 ">Input </td>
<td align="left" valign="top" width="47.03703703703704%" headers="d0e55 ">Buffer that might contain a <span class="synph"><span class="var">pattern-value</span></span> to
qualify the result set by <span>procedure</span> name.</td>
</tr>
<tr><td align="left" valign="top" width="17.59259259259259%" headers="d0e49 ">SQLCHAR *</td>
<td align="left" valign="top" width="23.51851851851852%" headers="d0e51 "><em>SchemaName</em> </td>
<td align="left" valign="top" width="11.851851851851853%" headers="d0e53 ">Input </td>
<td align="left" valign="top" width="47.03703703703704%" headers="d0e55 ">Buffer that might contain a <span class="synph"><span class="var">pattern-value</span></span> to
qualify the result set by schema name. <p>For DB2 Universal Database™ for z/OS<sup>®</sup> and OS/390<sup>®</sup> V
4.1, all the stored procedures are in one schema; the only acceptable value
for the <span class="synph"><span class="var">SchemaName</span></span> argument is a null pointer. For DB2
Universal Database™, <span class="synph"><span class="var">SchemaName</span></span> can contain
a valid pattern value.</p>
</td>
</tr>
<tr><td align="left" valign="top" width="17.59259259259259%" headers="d0e49 ">SQLHSTMT </td>
<td align="left" valign="top" width="23.51851851851852%" headers="d0e51 "><em>StatementHandle</em> </td>
<td align="left" valign="top" width="11.851851851851853%" headers="d0e53 ">Input </td>
<td align="left" valign="top" width="47.03703703703704%" headers="d0e55 ">Statement handle.</td>
</tr>
<tr><td align="left" valign="top" width="17.59259259259259%" headers="d0e49 ">SQLSMALLINT </td>
<td align="left" valign="top" width="23.51851851851852%" headers="d0e51 "><em>NameLength2</em> </td>
<td align="left" valign="top" width="11.851851851851853%" headers="d0e53 ">Input </td>
<td align="left" valign="top" width="47.03703703703704%" headers="d0e55 ">Length of <span class="synph"><span class="var">SchemaName</span></span>.</td>
</tr>
<tr><td align="left" valign="top" width="17.59259259259259%" headers="d0e49 ">SQLSMALLINT </td>
<td align="left" valign="top" width="23.51851851851852%" headers="d0e51 "><em>NameLength3</em> </td>
<td align="left" valign="top" width="11.851851851851853%" headers="d0e53 ">Input</td>
<td align="left" valign="top" width="47.03703703703704%" headers="d0e55 ">Length of <span class="synph"><span class="var">ProcName</span></span>.</td>
</tr>
<tr><td align="left" valign="top" width="17.59259259259259%" headers="d0e49 ">SQLSMALLINT</td>
<td align="left" valign="top" width="23.51851851851852%" headers="d0e51 "><em>NameLength1</em> </td>
<td align="left" valign="top" width="11.851851851851853%" headers="d0e53 ">Input </td>
<td align="left" valign="top" width="47.03703703703704%" headers="d0e55 ">Length of <span class="synph"><span class="var">CatalogName</span></span>.
This must be set to 0.</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section"><h4 class="sectiontitle">Usage</h4><p>The result set returned by <samp class="codeph">SQLProcedures()</samp> contains
the columns listed in <a href="#rzadpfnprcs__pstabls">Table 2</a> in the order
given. The rows are ordered by PROCEDURE_CAT, PROCEDURE_SCHEMA, and PROCEDURE_NAME.</p>
<p>Because
calls to <samp class="codeph">SQLProcedures()</samp> in many cases map to a complex and
thus expensive query against the system catalog, use them sparingly, and save
the results rather than repeating calls.</p>
<p>Although new columns might
be added and the names of the existing columns might be changed in future
releases, the position of the current columns does not change.</p>
<div class="tablenoborder"><a name="rzadpfnprcs__pstabls"><!-- --></a><table cellpadding="4" cellspacing="0" summary="" id="rzadpfnprcs__pstabls" width="100%" frame="hsides" border="1" rules="rows"><caption>Table 2. Columns returned by SQLProcedures</caption><thead align="left"><tr><th align="left" valign="top" width="30%" id="d0e210">Column number/name</th>
<th align="left" valign="top" width="16.666666666666664%" id="d0e212">Data type</th>
<th align="left" valign="top" width="53.333333333333336%" id="d0e214">Description</th>
</tr>
</thead>
<tbody><tr><td align="left" valign="top" width="30%" headers="d0e210 ">PROCEDURE_CAT </td>
<td align="left" valign="top" width="16.666666666666664%" headers="d0e212 ">VARCHAR(128) </td>
<td align="left" valign="top" width="53.333333333333336%" headers="d0e214 ">The current server.</td>
</tr>
<tr><td align="left" valign="top" width="30%" headers="d0e210 ">PROCEDURE_SCHEM </td>
<td align="left" valign="top" width="16.666666666666664%" headers="d0e212 ">VARCHAR(128) </td>
<td align="left" valign="top" width="53.333333333333336%" headers="d0e214 ">The name of the schema containing PROCEDURE_NAME.</td>
</tr>
<tr><td align="left" valign="top" width="30%" headers="d0e210 ">PROCEDURE_NAME </td>
<td align="left" valign="top" width="16.666666666666664%" headers="d0e212 ">VARCHAR(128) NOT NULL</td>
<td align="left" valign="top" width="53.333333333333336%" headers="d0e214 ">The name of the procedure.</td>
</tr>
<tr><td align="left" valign="top" width="30%" headers="d0e210 ">NUM_INPUT_PARAMS</td>
<td align="left" valign="top" width="16.666666666666664%" headers="d0e212 ">INTEGER not NULL</td>
<td align="left" valign="top" width="53.333333333333336%" headers="d0e214 ">Number of input parameters. <p>This column
should not be used, it is reserved for future use by ODBC.</p>
<p>It
is used in versions of DB2<sup>®</sup> UDB CLI before version 5. For backward compatibility
it can be used with the old DB2CLI.PROCEDURES pseudo catalog table (by setting
the PATCH1 CLI/ODBC Configuration keyword).</p>
</td>
</tr>
<tr><td align="left" valign="top" width="30%" headers="d0e210 ">NUM_OUTPUT_PARAMS</td>
<td align="left" valign="top" width="16.666666666666664%" headers="d0e212 ">INTEGER not NULL</td>
<td align="left" valign="top" width="53.333333333333336%" headers="d0e214 ">Number of output parameters. <p>This column
should not be used, it is reserved for future use by ODBC.</p>
<p>It was used
in versions of DB2 UDB
CLI before version 5. For backward compatibility it can be used with the old
DB2CLI.PROCEDURES pseudo catalog table (by setting the PATCH1 CLI/ODBC Configuration
keyword).</p>
</td>
</tr>
<tr><td align="left" valign="top" width="30%" headers="d0e210 ">NUM_RESULT_SETS</td>
<td align="left" valign="top" width="16.666666666666664%" headers="d0e212 ">INTEGER not NULL</td>
<td align="left" valign="top" width="53.333333333333336%" headers="d0e214 ">Number of result sets returned by the procedure.
<p>This column should not be used, it is reserved for future use by ODBC.</p>
<p>It
was used in versions of DB2 UDB CLI before version 5. For backward compatibility
it can be used with the old DB2CLI.PROCEDURES pseudo catalog table (by setting
the PATCH1 CLI/ODBC Configuration keyword).</p>
</td>
</tr>
<tr><td align="left" valign="top" width="30%" headers="d0e210 ">REMARKS </td>
<td align="left" valign="top" width="16.666666666666664%" headers="d0e212 ">VARCHAR(254) </td>
<td align="left" valign="top" width="53.333333333333336%" headers="d0e214 ">Contains the descriptive information about
the procedure.</td>
</tr>
<tr><td colspan="3" align="left" valign="top" headers="d0e210 d0e212 d0e214 "><div class="note"><span class="notetitle">Note:</span> The column
names used by DB2 UDB
CLI follow the X/Open CLI CAE specification style. The column types, contents
and order are identical to those defined for the <samp class="codeph">SQLProcedures()</samp> result
set in ODBC.</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section"><h4 class="sectiontitle">Return codes</h4><div class="p"> <ul><li>SQL_SUCCESS</li>
<li>SQL_SUCCESS_WITH_INFO</li>
<li>SQL_STILL_EXECUTING</li>
<li>SQL_ERROR</li>
<li>SQL_INVALID_HANDLE</li>
</ul>
</div>
</div>
<div class="section"><h4 class="sectiontitle">Error conditions</h4>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" width="100%" frame="hsides" border="1" rules="rows"><caption>Table 3. SQLProcedures SQLSTATEs</caption><thead align="left"><tr><th align="left" valign="bottom" width="12.962962962962962%" id="d0e330">SQLSTATE </th>
<th align="left" valign="bottom" width="29.074074074074076%" id="d0e332">Description </th>
<th align="left" valign="bottom" width="57.96296296296296%" id="d0e334">Explanation </th>
</tr>
</thead>
<tbody><tr><td align="left" valign="top" width="12.962962962962962%" headers="d0e330 "><strong>24</strong>000 </td>
<td align="left" valign="top" width="29.074074074074076%" headers="d0e332 ">Cursor state that is not valid</td>
<td align="left" valign="top" width="57.96296296296296%" headers="d0e334 ">A cursor is already opened on the statement
handle.</td>
</tr>
<tr><td align="left" valign="top" width="12.962962962962962%" headers="d0e330 "><strong>40</strong>003 <strong>08</strong>S01</td>
<td align="left" valign="top" width="29.074074074074076%" headers="d0e332 ">Communication link failure</td>
<td align="left" valign="top" width="57.96296296296296%" headers="d0e334 ">The communication link between the application
and data source fails before the function is completed.</td>
</tr>
<tr><td align="left" valign="top" width="12.962962962962962%" headers="d0e330 "><strong>HY</strong>001 </td>
<td align="left" valign="top" width="29.074074074074076%" headers="d0e332 ">Memory allocation failure</td>
<td align="left" valign="top" width="57.96296296296296%" headers="d0e334 ">DB2 UDB CLI is unable to allocate memory
required to support the processing or completion of the function.</td>
</tr>
<tr><td align="left" valign="top" width="12.962962962962962%" headers="d0e330 "><strong>HY</strong>008</td>
<td align="left" valign="top" width="29.074074074074076%" headers="d0e332 ">Operation canceled</td>
<td align="left" valign="top" width="57.96296296296296%" headers="d0e334 ">&nbsp;</td>
</tr>
<tr><td align="left" valign="top" width="12.962962962962962%" headers="d0e330 "><strong>HY</strong>010 </td>
<td align="left" valign="top" width="29.074074074074076%" headers="d0e332 ">Function sequence error</td>
<td align="left" valign="top" width="57.96296296296296%" headers="d0e334 ">&nbsp;</td>
</tr>
<tr><td align="left" valign="top" width="12.962962962962962%" headers="d0e330 "><strong>HY</strong>014 </td>
<td align="left" valign="top" width="29.074074074074076%" headers="d0e332 ">No more handles</td>
<td align="left" valign="top" width="57.96296296296296%" headers="d0e334 ">DB2 UDB CLI is unable to allocate a handle
due to internal resources.</td>
</tr>
<tr><td valign="top" width="12.962962962962962%" headers="d0e330 "><strong>HY</strong>021</td>
<td valign="top" width="29.074074074074076%" headers="d0e332 ">Internal descriptor that is not valid </td>
<td valign="top" width="57.96296296296296%" headers="d0e334 ">The internal descriptor cannot be addressed or allocated,
or it contains a value that is not valid.</td>
</tr>
<tr><td align="left" valign="top" width="12.962962962962962%" headers="d0e330 "><strong>HY</strong>090 </td>
<td align="left" valign="top" width="29.074074074074076%" headers="d0e332 ">String or buffer length that is not valid</td>
<td align="left" valign="top" width="57.96296296296296%" headers="d0e334 ">The value of one of the name length arguments
is less than 0, but not equal to SQL_NTS.</td>
</tr>
<tr><td align="left" valign="top" width="12.962962962962962%" headers="d0e330 "><strong>HY</strong>C00 </td>
<td align="left" valign="top" width="29.074074074074076%" headers="d0e332 ">Driver not capable</td>
<td align="left" valign="top" width="57.96296296296296%" headers="d0e334 ">DB2 UDB CLI does not support <span class="synph"><span class="var">catalog</span></span> as
a qualifier for procedure name. <p>The connected server does not support
schema as a qualifier for procedure name.</p>
</td>
</tr>
<tr><td align="left" valign="top" width="12.962962962962962%" headers="d0e330 "><strong>HY</strong>T00 </td>
<td align="left" valign="top" width="29.074074074074076%" headers="d0e332 ">Timeout expired</td>
<td align="left" valign="top" width="57.96296296296296%" headers="d0e334 ">&nbsp;</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section"><h4 class="sectiontitle">Restrictions</h4><p> If an application is connected to
a DB2 server
that does not provide support for a stored procedure catalog, or does not
provide support for stored procedures, <samp class="codeph">SQLProcedureColumns()</samp> returns
an empty result set.</p>
</div>
<div class="section"><h4 class="sectiontitle">Example</h4></div>
<div class="example" id="rzadpfnprcs__xmprcs"><a name="rzadpfnprcs__xmprcs"><!-- --></a><div class="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>/* From CLI sample procs.c */
/* ... */
printf("Enter Procedure Schema Name Search Pattern:\n");
gets((char *)proc_schem.s);
rc = SQLProcedures(hstmt, NULL, 0, proc_schem.s, SQL_NTS, (SQLCHAR *)"%", SQL_NTS);
CHECK_HANDLE( SQL_HANDLE_STMT, hstmt, rc ) ;
rc = SQLBindCol(hstmt, 2, SQL_C_CHAR, (SQLPOINTER) proc_schem.s, 129,
&amp;proc_schem.ind);
CHECK_HANDLE( SQL_HANDLE_STMT, hstmt, rc ) ;
rc = SQLBindCol(hstmt, 3, SQL_C_CHAR, (SQLPOINTER) proc_name.s, 129,
&amp;proc_name.ind);
CHECK_HANDLE( SQL_HANDLE_STMT, hstmt, rc ) ;
rc = SQLBindCol(hstmt, 7, SQL_C_CHAR, (SQLPOINTER) remarks.s, 255,
&amp;remarks.ind);
CHECK_HANDLE( SQL_HANDLE_STMT, hstmt, rc ) ;
printf("PROCEDURE SCHEMA PROCEDURE NAME \n");
printf("------------------------- ------------------------- \n");
/* Fetch each row, and display */
while ((rc = SQLFetch(hstmt)) == SQL_SUCCESS) {
printf("%-25s %-25s\n", proc_schem.s, proc_name.s);
if (remarks.ind != SQL_NULL_DATA) {
printf(" (Remarks) %s\n", remarks.s);
}
} /* endwhile */</pre>
</div>
</div>
<div class="section"><h4 class="sectiontitle">References</h4><div class="p"> <ul><li><a href="rzadpfnprcco.htm#rzadpfnprcco">SQLProcedureColumns - Get input/output parameter information for a procedure</a></li>
</ul>
</div>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="rzadphdapi.htm" title="This topic provides a description of each CLI function.">DB2 UDB CLI functions</a></div>
</div>
</div>
</body>
</html>