getProcedures 方法 (SQLServerDatabaseMetaData)getProcedures Method (SQLServerDatabaseMetaData)
01/19/2017
本文內容
擷取可依給定目錄、結構描述或預存程序名稱模式取得之預存程序的描述。Retrieves a description of the stored procedures that are available in the given catalog, schema, or stored procedure name pattern.
語法Syntax
public java.sql.ResultSet getProcedures(java.lang.String sCatalog,
java.lang.String sSchema,
java.lang.String proc)
參數Parameters
sCatalogsCatalog
包含目錄名稱的 String。A String that contains the catalog name. 提供 null 給這個參數,將指出不需要使用目錄名稱。Providing a null to this parameter indicates that the catalog name does not need to be used.
sSchemasSchema
包含結構描述名稱模式的 String。A String that contains the schema name pattern. 提供 null 給這個參數,將指出不需要使用結構描述名稱。Providing a null to this parameter indicates that the schema name does not need to be used.
procproc
包含程序名稱模式的字串。A String that contains the procedure name pattern.
傳回值Return Value
例外狀況Exceptions
備註Remarks
這個 getProcedures 方法是由 java.sql.DatabaseMetaData 介面中的 getProcedures 方法所指定。This getProcedures method is specified by the getProcedures method in the java.sql.DatabaseMetaData interface.
透過 getProcedures 方法所傳回的結果將包含下列資訊:The result set returned by the getProcedures method will contain the following information:
名稱Name
類型Type
描述Description
PROCEDURE_CATPROCEDURE_CAT
StringString
指定之預存程序所在之資料庫的名稱。The name of the database in which the specified stored procedure resides.
PROCEDURE_SCHEMPROCEDURE_SCHEM
StringString
預存程序的結構描述。The schema for the stored procedure.
PROCEDURE_NAMEPROCEDURE_NAME
StringString
預存程序的名稱。The name of the stored procedure.
NUM_INPUT_PARAMSNUM_INPUT_PARAMS
intint
保留供日後使用,目前會傳回值 -1。Reserved for future use, currently returns a -1 value.
NUM_OUTPUT_PARAMSNUM_OUTPUT_PARAMS
intint
保留供日後使用,目前會傳回值 -1。Reserved for future use, currently returns a -1 value.
NUM_RESULT_SETSNUM_RESULT_SETS
intint
保留供日後使用,目前會傳回值 -1。Reserved for future use, currently returns a -1 value.
REMARKSREMARKS
StringString
程序資料行的描述。The description of the procedure column.
注意: SQL ServerSQL Server 不會傳回這個資料行的值。Note: SQL ServerSQL Server does not return a value for this column.
PROCEDURE_TYPEPROCEDURE_TYPE
smallintsmallint
預存程序的類型。The type of stored procedure. 它可能是下列其中一個值:It can be one of the following values:
SQL_PT_UNKNOWN (0)SQL_PT_UNKNOWN (0)
SQL_PT_PROCEDURE (1)SQL_PT_PROCEDURE (1)
SQL_PT_FUNCTION (2)SQL_PT_FUNCTION (2)
注意
如需 getProcedures 方法所傳回資料的詳細資訊,請參閱《SQL ServerSQL Server 線上叢書》中的<sp_stored_procedures (Transact-SQL)>。For more information about the data returned by the getProcedures method, see "sp_stored_procedures (Transact-SQL)" in SQL ServerSQL Server Books Online.
範例Example
下列範例會示範如何使用 getProcedures 方法來傳回 AdventureWorksAdventureWorks 範例資料庫中 uspGetBillOfMaterials 預存程序的相關資訊。The following example demonstrates how to use the getProcedures method to return information about the uspGetBillOfMaterials stored procedure in the AdventureWorksAdventureWorks sample database.
public static void executeGetProcedures(Connection con) {
try {
DatabaseMetaData dbmd = con.getMetaData();
ResultSet rs = dbmd.getProcedures(null, null, "uspGetBillOfMaterials");
ResultSetMetaData rsmd = rs.getMetaData();
// Display the result set data.
int cols = rsmd.getColumnCount();
while(rs.next()) {
for (int i = 1; i <= cols; i++) {
System.out.println(rs.getString(i));
}
}
rs.close();
}
catch (Exception e) {
e.printStackTrace();
}
}
另請參閱See Also