SQLRETURN SQLProcedures (
SQLHSTMT StatementHandle, /* hstmt */
SQLCHAR *CatalogName, /* szProcCatalog */
SQLSMALLINT NameLength1, /* cbProcCatalog */
SQLCHAR *SchemaName, /* szProcSchema */
SQLSMALLINT NameLength2, /* cbProcSchema */
SQLCHAR *ProcName, /* szProcName */
SQLSMALLINT NameLength3); /* cbProcName */
Data type | Argument | Use | Description |
---|---|---|---|
SQLHSTMT | StatementHandle | Input | The statement handle. |
SQLCHAR * | CatalogName | Input | A catalog qualifier of a 3-part table name. If the target DBMS does not support 3-part naming, and CatalogName is not a null pointer and does not point to a zero-length string, then an empty result set and SQL_SUCCESS is returned. Otherwise, this is a valid filter for DBMSs that support 3-part naming. |
SQLSMALLINT | NameLength1 | Input | The number of SQLCHAR elements (or SQLWCHAR elements for the Unicode variant of this function) that are required to store CatalogName, or SQL_NTS if CatalogName is null-terminated. |
SQLCHAR * | SchemaName | Input | A buffer that can contain a pattern value to qualify the result set by schema name. For DB2® for z/OS®, the stored procedures are in one schema; the only acceptable value for the SchemaName argument is a null pointer. If a value is specified, an empty result set and SQL_SUCCESS are returned. For DB2 for Linux, UNIX, and Windows, SchemaName can contain a valid pattern value. For more information about valid search patterns, see the catalog functions input arguments. |
SQLSMALLINT | NameLength2 | Input | The number of SQLCHAR elements (or SQLWCHAR elements for the Unicode variant of this function) that are required to store SchemaName, or SQL_NTS if SchemaName is null-terminated. |
SQLCHAR * | ProcName | Input | A buffer that can contain a pattern value to qualify the result set by table name. |
SQLSMALLINT | NameLength3 | Input | The number of SQLCHAR elements (or SQLWCHAR elements for the Unicode variant of this function) that are required to store ProcName, or SQL_NTS if ProcName is null-terminated. |
The result set that is returned by the SQLProcedures() function contains the columns that are listed in Columns returned by SQLProcedures in the order given. The rows are ordered by PROCEDURE_CAT, PROCEDURE_SCHEMA, and PROCEDURE_NAME.
In many cases, calls to the SQLProcedures() function map to a complex and thus expensive query against the system catalog, so you should use them sparingly, and save the results rather than repeating calls.
Call SQLGetInfo() with the SQL_MAX_CATALOG_NAME_LEN, SQL_MAX_SCHEMA_NAME_LEN, SQL_MAX_TABLE_NAME_LEN, and SQL_MAX_COLUMN_NAME_LEN to determine the actual lengths of the TABLE_CAT, TABLE_SCHEM, TABLE_NAME, and COLUMN_NAME columns that are supported by the connected DBMS.
If the SQL_ATTR_LONGDATA_COMPAT connection attribute is set, LOB column types are reported as LONG VARCHAR, LONG VARBINARY, or LONG VARGRAPHIC types.
If the stored procedure is at a DB2 for z/OS server, the name of the stored procedures must be registered in the server's SYSIBM.SYSPROCEDURES catalog table. For V8 and later servers, the stored procedure must be registered in the server's SYSIBM.SYSROUTINES and SYSIBM.SYSPARAMS catalog tables.
For other versions of DB2 servers that do not provide facilities for a stored procedure catalog, an empty result set is returned.
You can specify *ALL as a value in the SchemaName to resolve unqualified stored procedure calls or to find libraries in catalog API calls. CLI searches on all existing schemas in the connected database. You are not required to specify *ALL, as this behavior is the default in CLI. Alternatively, you can set the SchemaFilter IBM® Data Server Driver configuration keyword or the Schema List CLI/ODBC configuration keyword to *ALL.
Although new columns might be added and the names of the existing columns changed in future releases, the position of the current columns will not change.
To determine information regarding INOUT parameters, examine the COLUMN_TYPE column that is returned by SQLProcedureColumns().
To determine information regarding INOUT parameters, examine the COLUMN_TYPE column that is returned by SQLProcedureColumns().
You should not use this column, it is reserved for future use by ODBC.
CLI always returns SQL_PT_PROCEDURE.
SQLSTATE | Description | Explanation |
---|---|---|
24000 | Invalid cursor state. | A cursor was already opened on the statement handle. |
40003 08S01 | Communication link failure. | The communication link between the application and data source failed before the function completed. |
HY001 | Memory allocation failure. | DB2 CLI is unable to allocate memory required to support execution or completion of the function. It is likely that process-level memory has been exhausted for the application process. Consult the operating system configuration for information about process-level memory limitations. |
HY008 | Operation was Canceled. | Asynchronous processing was enabled for StatementHandle. The function was called and before it completed execution, SQLCancel() was called on StatementHandle from a different thread in a multithreaded application. The function was called again on StatementHandle. |
HY010 | Function sequence error. | The function was called while in a data-at-execute (SQLParamData(), SQLPutData()) operation. The function was called while within a BEGIN COMPOUND and END COMPOUND SQL operation. An asynchronously executing function (not this one) was called for the StatementHandle and was still executing when this function was called. The function was called before a statement was prepared on the statement handle. |
HY014 | No more handles. | DB2 CLI was unable to allocate a handle due to resource limitations. |
HY090 | Invalid string or buffer length. | The value of one of the name-length arguments was less than 0, but not equal to SQL_NTS. |
HYT00 | Timeout expired. | The timeout period expired before the data source returned the result set. You can set timeout period by using the SQL_ATTR_QUERY_TIMEOUT attribute for SQLSetStmtAttr(). |
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, SQLProcedureColumns() will return an empty result set.