SQLProcedures 函数SQLProcedures Function

符合性Conformance
版本引入了:ODBC 1.0 标准符合性:ODBCVersion Introduced: ODBC 1.0 Standards Compliance: ODBC

摘要Summary
SQLProcedures返回的特定数据源中存储的过程名称的列表。SQLProcedures returns the list of procedure names stored in a specific data source. 过程是用于描述一个通用术语可执行对象,或已命名的实体,可以使用输入和输出参数进行调用。Procedure is a generic term used to describe an executable object, or a named entity that can be invoked using input and output parameters. 有关过程的详细信息,请参阅过程For more information on procedures, see the Procedures.

语法Syntax

  
SQLRETURN SQLProcedures(  
     SQLHSTMT       StatementHandle,  
     SQLCHAR *      CatalogName,  
     SQLSMALLINT    NameLength1,  
     SQLCHAR *      SchemaName,  
     SQLSMALLINT    NameLength2,  
     SQLCHAR *      ProcName,  
     SQLSMALLINT    NameLength3);  

参数Arguments

StatementHandleStatementHandle
[输入]语句句柄。[Input] Statement handle.

CatalogNameCatalogName
[输入]过程目录。[Input] Procedure catalog. 如果驱动程序支持目录有关的某些表而不是其他人,例如当驱动程序检索数据从不同 Dbms,空字符串 ("") 表示没有目录的那些表。If a driver supports catalogs for some tables but not for others, such as when the driver retrieves data from different DBMSs, an empty string ("") denotes those tables that do not have catalogs. CatalogName不能包含字符串的搜索模式。CatalogName cannot contain a string search pattern.

如果 SQL_ATTR_METADATA_ID 语句属性设置为 SQL_TRUE, CatalogName视为标识符和其大小写并不重要。If the SQL_ATTR_METADATA_ID statement attribute is set to SQL_TRUE, CatalogName is treated as an identifier and its case is not significant. SQL_FALSE,若是CatalogName是普通参数; 按字面意思,处理和其大小写很重要。If it is SQL_FALSE, CatalogName is an ordinary argument; it is treated literally, and its case is significant. 有关详细信息,请参阅中目录函数的自变量For more information, see Arguments in Catalog Functions.

NameLength1NameLength1
[输入]以字符为单位的长度 *CatalogName[Input] Length in characters of *CatalogName.

SchemaNameSchemaName
[输入]过程架构名称的字符串搜索模式。[Input] String search pattern for procedure schema names. 如果驱动程序支持的架构,对于一些过程,但对于其他操作系统,例如当驱动程序检索数据从不同 Dbms,空字符串 ("") 表示不具有架构的这些过程。If a driver supports schemas for some procedures but not for others, such as when the driver retrieves data from different DBMSs, an empty string ("") denotes those procedures that do not have schemas.

如果 SQL_ATTR_METADATA_ID 语句属性设置为 SQL_TRUE, SchemaName视为标识符和其大小写并不重要。If the SQL_ATTR_METADATA_ID statement attribute is set to SQL_TRUE, SchemaName is treated as an identifier and its case is not significant. SQL_FALSE,若是SchemaName是模式值自变量; 按字面意思,处理和其大小写很重要。If it is SQL_FALSE, SchemaName is a pattern value argument; it is treated literally, and its case is significant.

NameLength2NameLength2
[输入]以字符为单位的长度 *SchemaName[Input] Length in characters of *SchemaName.

ProcNameProcName
[输入]过程名称的字符串搜索模式。[Input] String search pattern for procedure names.

如果 SQL_ATTR_METADATA_ID 语句属性设置为 SQL_TRUE, ProcName视为标识符和其大小写并不重要。If the SQL_ATTR_METADATA_ID statement attribute is set to SQL_TRUE, ProcName is treated as an identifier and its case is not significant. SQL_FALSE,若是ProcName是模式值自变量; 按字面意思,处理和其大小写很重要。If it is SQL_FALSE, ProcName is a pattern value argument; it is treated literally, and its case is significant.

NameLength3NameLength3
[输入]以字符为单位的长度 *ProcName[Input] Length in characters of *ProcName.

返回Returns

SQL_SUCCESS、 SQL_SUCCESS_WITH_INFO、 SQL_STILL_EXECUTING、 SQL_ERROR 或 SQL_INVALID_HANDLE。SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_STILL_EXECUTING, SQL_ERROR, or SQL_INVALID_HANDLE.

诊断Diagnostics

SQLProcedures返回 SQL_ERROR 或 SQL_SUCCESS_WITH_INFO,关联的 SQLSTATE 值可以通过调用来获取SQLGetDiagRecHandleType的 SQL_HANDLE_STMT 和一个处理StatementHandleWhen SQLProcedures returns SQL_ERROR or SQL_SUCCESS_WITH_INFO, an associated SQLSTATE value can be obtained by calling SQLGetDiagRec with a HandleType of SQL_HANDLE_STMT and a Handle of StatementHandle. 下表列出了通常返回的 SQLSTATE 值SQLProcedures ,并解释了此函数; 每个上下文中的表示法"(数据挖掘)"之前 SQLSTATEs 返回由驱动程序管理器的说明。The following table lists the SQLSTATE values commonly returned by SQLProcedures and explains each one in the context of this function; the notation "(DM)" precedes the descriptions of SQLSTATEs returned by the Driver Manager. 与每个 SQLSTATE 值关联的返回代码是 SQL_ERROR,除非另有说明。The return code associated with each SQLSTATE value is SQL_ERROR, unless noted otherwise.

SQLSTATESQLSTATE ErrorError 描述Description
0100001000 常规警告General warning 特定于驱动程序的信息性消息。Driver-specific informational message. (函数返回 SQL_SUCCESS_WITH_INFO。)(Function returns SQL_SUCCESS_WITH_INFO.)
08S0108S01 通讯链接失败Communication link failure 该驱动程序和驱动程序已连接到数据源之间的通信链接失败之前函数已完成处理。The communication link between the driver and the data source to which the driver was connected failed before the function completed processing.
2400024000 游标状态无效Invalid cursor state 在打开游标的StatementHandle,并SQLFetchSQLFetchScroll已调用一样。A cursor was open on the StatementHandle, and SQLFetch or SQLFetchScroll had been called. 如果此错误返回由驱动程序管理器SQLFetchSQLFetchScroll未返回 SQL_NO_DATA,和如果驱动程序返回SQLFetchSQLFetchScroll已返回 sql_no_data 为止。This error is returned by the Driver Manager if SQLFetch or SQLFetchScroll has not returned SQL_NO_DATA, and is returned by the driver if SQLFetch or SQLFetchScroll has returned SQL_NO_DATA.

在打开游标的StatementHandle,但SQLFetchSQLFetchScroll尚未调用。A cursor was open on the StatementHandle, but SQLFetch or SQLFetchScroll had not been called.
4000140001 序列化失败Serialization failure 事务已回滚,由于其他事务与资源死锁。The transaction was rolled back due to a resource deadlock with another transaction.
4000340003 语句完成情况未知Statement completion unknown 此函数中,在执行期间失败关联的连接,无法确定事务的状态。The associated connection failed during the execution of this function, and the state of the transaction cannot be determined.
HY000HY000 常规错误General error 有关其中没有任何特定的 SQLSTATE 和为其定义任何特定于实现的 SQLSTATE 出错。An error occurred for which there was no specific SQLSTATE and for which no implementation-specific SQLSTATE was defined. 返回的错误消息SQLGetDiagRec*MessageText缓冲区描述错误以及其原因。The error message returned by SQLGetDiagRec in the *MessageText buffer describes the error and its cause.
HY001HY001 内存分配错误Memory allocation error 该驱动程序无法分配支持执行或完成该函数所需的内存。The driver was unable to allocate memory required to support execution or completion of the function.
HY008HY008 操作已取消Operation canceled 异步处理的已启用StatementHandleAsynchronous processing was enabled for the StatementHandle. 调用该函数,和之前执行完毕SQLCancelSQLCancelHandle上调用了StatementHandleThe function was called, and before it completed execution, SQLCancel or SQLCancelHandle was called on the StatementHandle. 然后在再次调用该函数StatementHandleThen the function was called again on the StatementHandle.

调用该函数,和之前执行完毕SQLCancelSQLCancelHandle上调用了StatementHandle来自不同线程中多线程应用程序。The function was called, and before it completed execution, SQLCancel or SQLCancelHandle was called on the StatementHandle from a different thread in a multithread application.
HY009HY009 使用空指针无效Invalid use of null pointer SQL_ATTR_METADATA_ID 语句属性设置为 SQL_TRUE, CatalogName参数为 null 指针和 SQL_CATALOG_NAME信息类型支持目录名称返回。The SQL_ATTR_METADATA_ID statement attribute was set to SQL_TRUE, the CatalogName argument was a null pointer, and the SQL_CATALOG_NAME InfoType returns that catalog names are supported.

(DM) SQL_ATTR_METADATA_ID 语句属性设置为 SQL_TRUE,并SchemaNameProcName参数是空指针。(DM) The SQL_ATTR_METADATA_ID statement attribute was set to SQL_TRUE, and the SchemaName or ProcName argument was a null pointer.
HY010HY010 函数序列错误Function sequence error (DM) 为与之关联的连接句柄调用以异步方式执行的函数StatementHandle(DM) An asynchronously executing function was called for the connection handle that is associated with the StatementHandle. 此异步函数仍在执行时调用此函数。This asynchronous function was still executing when this function was called.

(数据挖掘) SQLExecuteSQLExecDirect,或SQLMoreResults曾为StatementHandle和返回 SQL_PARAM_DATA_可用。(DM) SQLExecute, SQLExecDirect, or SQLMoreResults was called for the StatementHandle and returned SQL_PARAM_DATA_AVAILABLE. 数据已检索到的所有经过流处理参数之前调用此函数。This function was called before data was retrieved for all streamed parameters.

(DM) 的调用以异步方式执行的函数 (不是此类似) StatementHandle和仍在执行时调用此函数。(DM) An asynchronously executing function (not this one) was called for the StatementHandle and was still executing when this function was called.

(数据挖掘) SQLExecuteSQLExecDirectSQLBulkOperations,或者SQLSetPos曾为StatementHandle和返回 SQL_NEED_DATA。(DM) SQLExecute, SQLExecDirect, SQLBulkOperations, or SQLSetPos was called for the StatementHandle and returned SQL_NEED_DATA. 数据已发送的所有执行时数据参数或列之前调用此函数。This function was called before data was sent for all data-at-execution parameters or columns.
HY013HY013 内存管理错误Memory management error 无法处理函数调用,因为基础内存对象无法访问,可能是由于内存不足的情况。The function call could not be processed because the underlying memory objects could not be accessed, possibly because of low memory conditions.
HY090HY090 字符串或缓冲区长度无效Invalid string or buffer length (DM) 之一的名称长度参数值小于 0 但不是等于 SQL_NTS。(DM) The value of one of the name length arguments was less than 0 but not equal to SQL_NTS.

名称长度参数之一的值超出相应名称的最大长度值。The value of one of the name length arguments exceeded the maximum length value for the corresponding name.
HY117HY117 由于未知的事务状态而挂起连接。Connection is suspended due to unknown transaction state. 仅断开连接,并允许使用只读的函数。Only disconnect and read-only functions are allowed. (DM) 有关挂起状态的详细信息,请参阅SQLEndTran 函数(DM) For more information about suspended state, see SQLEndTran Function.
HYC00HYC00 未实现的可选功能Optional feature not implemented 指定过程目录,并在驱动程序或数据源不支持目录。A procedure catalog was specified, and the driver or data source does not support catalogs.

指定过程的架构,并在驱动程序或数据源不支持架构。A procedure schema was specified, and the driver or data source does not support schemas.

为过程架构或过程名称,指定字符串的搜索模式和数据源不支持的一个或多个这些参数的搜索模式。A string search pattern was specified for the procedure schema or procedure name, and the data source does not support search patterns for one or more of those arguments.

驱动程序或数据源不支持 SQL_ATTR_CONCURRENCY 和 SQL_ATTR_CURSOR_TYPE 语句属性的当前设置的组合。The combination of the current settings of the SQL_ATTR_CONCURRENCY and SQL_ATTR_CURSOR_TYPE statement attributes was not supported by the driver or data source.

SQL_ATTR_USE_BOOKMARKS 语句属性设置为 SQL_UB_VARIABLE,并且 SQL_ATTR_CURSOR_TYPE 语句属性设置为游标类型,该驱动程序不支持书签。The SQL_ATTR_USE_BOOKMARKS statement attribute was set to SQL_UB_VARIABLE, and the SQL_ATTR_CURSOR_TYPE statement attribute was set to a cursor type for which the driver does not support bookmarks.
HYT00HYT00 超时时间已到Timeout expired 查询超时期限过期之前请求的结果集返回的数据源。The query timeout period expired before the data source returned the requested result set. 通过设置超时期限SQLSetStmtAttr,SQL_ATTR_QUERY_TIMEOUT。The timeout period is set through SQLSetStmtAttr, SQL_ATTR_QUERY_TIMEOUT.
HYT01HYT01 连接超时时间已到Connection timeout expired 连接超时期限过期之前的数据源响应此请求。The connection timeout period expired before the data source responded to the request. 通过设置连接超时期SQLSetConnectAttr,SQL_ATTR_CONNECTION_TIMEOUT。The connection timeout period is set through SQLSetConnectAttr, SQL_ATTR_CONNECTION_TIMEOUT.
IM001IM001 驱动程序不支持此函数Driver does not support this function (DM) 驱动程序与相关联StatementHandle不支持此函数。(DM) The driver associated with the StatementHandle does not support this function.
IM017IM017 轮询异步通知模式中禁用Polling is disabled in asynchronous notification mode 只要使用通知模型,将禁用轮询。Whenever the notification model is used, polling is disabled.
IM018IM018 SQLCompleteAsync尚未调用以完成此句柄上以前的异步操作。SQLCompleteAsync has not been called to complete the previous asynchronous operation on this handle. 如果句柄上的上一个函数调用返回 SQL_STILL_EXECUTING,如果启用通知模式,则SQLCompleteAsync必须要对其进行后期处理并完成该操作的句柄上调用。If the previous function call on the handle returns SQL_STILL_EXECUTING and if notification mode is enabled, SQLCompleteAsync must be called on the handle to do post-processing and complete the operation.

注释Comments

SQLProcedures列出了所请求的范围中的所有过程。SQLProcedures lists all procedures in the requested range. 用户可能会或可能没有执行任何这些过程的权限。A user may or may not have permission to execute any of these procedures. 若要检查辅助功能,应用程序可以调用SQLGetInfo并检查 SQL_ACCESSIBLE_PROCEDURES 信息值。To check accessibility, an application can call SQLGetInfo and check the SQL_ACCESSIBLE_PROCEDURES information value. 否则,应用程序必须能够处理的情况下,其中用户选择不能执行的过程。Otherwise, the application must be able to handle a situation where the user selects a procedure that it cannot execute. 有关可以如何使用此信息的信息,请参阅过程For information about how this information might be used, see Procedures.

备注

有关常规使用、 参数以及 ODBC 目录函数返回的数据的详细信息,请参阅目录函数For more information about the general use, arguments, and returned data of ODBC catalog functions, see Catalog Functions.

SQLProcedures以按 PROCEDURE_CAT、 PROCEDURE_SCHEMA 和 PROCEDURE_NAME 标准结果集的形式返回结果。SQLProcedures returns the results as a standard result set, ordered by PROCEDURE_CAT, PROCEDURE_SCHEMA, and PROCEDURE_NAME.

备注

SQLProcedures可能不会返回所有过程。SQLProcedures might not return all procedures. 应用程序可以使用任何有效的过程,而不考虑是否返回由SQLProceduresApplications can use any valid procedure, regardless of whether it is returned by SQLProcedures.

以下各列已重命名为 ODBC 3 .xThe following columns have been renamed for ODBC 3 .x. 列名称更改不会影响后向兼容性,因为应用程序将绑定的列号。The column name changes do not affect backward compatibility because applications bind by column number.

ODBC 2.0 列ODBC 2.0 column ODBC 3 .xODBC 3 .x column
PROCEDURE_QUALIFIERPROCEDURE_QUALIFIER PROCEDURE_CATPROCEDURE_CAT
过程 _OWNERPROCEDURE _OWNER 过程 _SCHEMPROCEDURE _SCHEM

若要确定 PROCEDURE_CAT、 PROCEDURE_SCHEM 和 PROCEDURE_NAME 列的实际长度,应用程序可以调用SQLGetInfo使用 SQL_MAX_CATALOG_NAME_LEN、 SQL_MAX_SCHEMA_NAME_LEN 和 SQL_MAX_PROCEDURE_NAME_LEN 选项。To determine the actual lengths of the PROCEDURE_CAT, PROCEDURE_SCHEM, and PROCEDURE_NAME columns, an application can call SQLGetInfo with the SQL_MAX_CATALOG_NAME_LEN, SQL_MAX_SCHEMA_NAME_LEN, and SQL_MAX_PROCEDURE_NAME_LEN options.

下表列出了在结果集中的列。The following table lists the columns in the result set. 列 8 (PROCEDURE_TYPE) 之外的其他列可以定义由驱动程序。Additional columns beyond column 8 (PROCEDURE_TYPE) can be defined by the driver. 应用程序应获得访问驱动程序特定列的结果集末尾的倒计时,而不是指定显式的序号位置。An application should gain access to driver-specific columns by counting down from the end of the result set rather than specifying an explicit ordinal position. 有关详细信息,请参阅目录函数返回数据For more information, see Data Returned by Catalog Functions.

列名Column name 列号Column number 数据类型Data type 注释Comments
PROCEDURE_CAT (ODBC 2.0)PROCEDURE_CAT (ODBC 2.0) 11 VarcharVarchar 过程目录标识符;如果不适用于数据源为 NULL。Procedure catalog identifier; NULL if not applicable to the data source. 如果驱动程序支持目录对于一些过程,但对于其他操作系统,如当驱动程序检索数据时从不同 Dbms,它返回空字符串 ("") 对于这些没有目录的过程。If a driver supports catalogs for some procedures but not for others, such as when the driver retrieves data from different DBMSs, it returns an empty string ("") for those procedures that do not have catalogs.
PROCEDURE_SCHEM (ODBC 2.0)PROCEDURE_SCHEM (ODBC 2.0) 22 VarcharVarchar 过程架构标识符;如果不适用于数据源为 NULL。Procedure schema identifier; NULL if not applicable to the data source. 如果驱动程序支持架构对于一些过程,但对于其他操作系统,如当驱动程序检索数据时从不同 Dbms,它返回空字符串 ("") 对于这些没有架构的过程。If a driver supports schemas for some procedures but not for others, such as when the driver retrieves data from different DBMSs, it returns an empty string ("") for those procedures that do not have schemas.
过程名称 (ODBC 2.0)PROCEDURE_NAME (ODBC 2.0) 33 Varchar 不为 NULLVarchar not NULL 过程标识符。Procedure identifier.
NUM_INPUT_PARAMS (ODBC 2.0)NUM_INPUT_PARAMS (ODBC 2.0) 44 不可用N/A 保留供将来使用。Reserved for future use. 应用程序不应依赖这些结果列中返回的数据。Applications should not rely on the data returned in these result columns.
NUM_OUTPUT_PARAMS (ODBC 2.0)NUM_OUTPUT_PARAMS (ODBC 2.0) 55 不可用N/A 保留供将来使用。Reserved for future use. 应用程序不应依赖这些结果列中返回的数据。Applications should not rely on the data returned in these result columns.
NUM_RESULT_SETS (ODBC 2.0)NUM_RESULT_SETS (ODBC 2.0) 66 不可用N/A 保留供将来使用。Reserved for future use. 应用程序不应依赖这些结果列中返回的数据。Applications should not rely on the data returned in these result columns.
备注 (ODBC 2.0)REMARKS (ODBC 2.0) 77 VarcharVarchar 对过程的说明。A description of the procedure.
PROCEDURE_TYPE (ODBC 2.0)PROCEDURE_TYPE (ODBC 2.0) 88 SmallintSmallint 定义过程类型:Defines the procedure type:

SQL_PT_UNKNOWN:无法确定该过程是否返回一个值。SQL_PT_UNKNOWN: It cannot be determined whether the procedure returns a value.

SQL_PT_PROCEDURE:返回的对象是过程;也就是说,它没有返回值。SQL_PT_PROCEDURE: The returned object is a procedure; that is, it does not have a return value.

SQL_PT_FUNCTION:返回的对象是一个函数;也就是说,它具有返回值。SQL_PT_FUNCTION: The returned object is a function; that is, it has a return value.

SchemaNameProcName参数接受搜索模式。The SchemaName and ProcName arguments accept search patterns. 有关有效的搜索模式的详细信息,请参阅模式值自变量For more information about valid search patterns, see Pattern Value Arguments.

代码示例Code Example

请参阅过程调用See Procedure Calls.

有关信息For information about 请参阅See
将缓冲区绑定到结果集中的列Binding a buffer to a column in a result set SQLBindCol 函数SQLBindCol Function
取消语句处理Canceling statement processing SQLCancel 函数SQLCancel Function
提取单个行或仅向前方向中的数据块Fetching a single row or a block of data in a forward-only direction SQLFetch 函数SQLFetch Function
提取的数据块或滚动浏览结果集Fetching a block of data or scrolling through a result set SQLFetchScroll 函数SQLFetchScroll Function
返回有关驱动程序或数据源的信息Returning information about a driver or data source SQLGetInfo 函数SQLGetInfo Function
返回参数和结果集列的过程Returning the parameters and result set columns of a procedure SQLProcedureColumns 函数SQLProcedureColumns Function
用于调用存储的过程的语法Syntax for invoking stored procedures 执行语句Executing Statements

请参阅See Also

ODBC API 参考 ODBC API Reference
ODBC 头文件ODBC Header Files