Compartir a través de


getProcedureColumns Method (SQLServerDatabaseMetaData)

Retrieves a description of the stored procedure parameters and result columns.

public java.sql.ResultSet getProcedureColumns(java.lang.String sCatalog,
                                              java.lang.String sSchema,
                                              java.lang.String proc,
                                              java.lang.String col)

Parámetros

sCatalog

A String that contains the catalog name. Providing a null to this parameter indicates that the catalog name does not need to be used.

sSchema

A String that contains the schema name pattern. Providing a null to this parameter indicates that the schema name does not need to be used.

proc

A String that contains the procedure name pattern.

col

A String that contains the column name pattern. Providing a null to this parameter returns a row for each column.

Valor devuelto

A SQLServerResultSet object.

Excepciones

SQLServerException

Notas

This getProcedureColumns method is specified by the getProcedureColumns method in the java.sql.DatabaseMetaData interface.

The result set returned by the getProcedureColumns method will contain the following information:

Name Type Description

PROCEDURE_CAT

String

The name of the database in which the specified stored procedure resides.

PROCEDURE_SCHEM

String

The schema for the stored procedure.

PROCEDURE_NAME

String

The name of the stored procedure.

COLUMN_NAME

String

The name of the column.

COLUMN_TYPE

short

The type of the column. It can be one of the following values:

procedureColumnUnknown (0)

procedureColumnIn (1)

procedureColumnInOut (2)

procedureColumnOut (4)

procedureColumnReturn (5)

procedureColumnResult (3)

DATA_TYPE

short

The SQL data type from java.sql.Types.

TYPE_NAME

String

The name of the data type.

PRECISION

int

The total number of significant digits.

LENGTH

int

The length of the data in bytes.

SCALE

short

The number of digits to the right of the decimal point.

RADIX

short

The base for numeric types.

NULLABLE

short

Indicates if the column can contain a null value. It can be one of the following values:

procedureNoNulls (0)

procedureNullable (1)

procedureNullableUnknown (2)

REMARKS

String

The description of the procedure column.

Nota

SQL Server does not return a value for this column.

COLUMN_DEF

String

The default value of the column.

SQL_DATA_TYPE

short

Not supported by the JDBC driver.

SQL_DATETIME_SUB

short

Not supported by the JDBC driver.

CHAR_OCTET_LENGTH

int

The maximum number of bytes in the column.

ORDINAL_POSITION

int

The index of the column within the table.

IS_NULLABLE

String

Indicates if the column allows null values.

SS_DATA_TYPE

short

The SQL Server data type that is used by extended stored procedures.

Nota

For more information about the data types returned by SQL Server, see "Data Types (Transact-SQL)" in SQL Server Books Online.

Nota

For more information about the data returned by the getProcedureColumns method, see "sp_sproc_columns (Transact-SQL)" in SQL Server Books Online.

Ejemplo

The following example demonstrates how to use the getProcedureColumns method to return information about the uspGetBillOfMaterials stored procedure in the SQL Server 2005 AdventureWorks sample database.

public static void executeGetProcedureColumns(Connection con) {
   try {
      DatabaseMetaData dbmd = con.getMetaData();
      ResultSet rs = dbmd.getProcedureColumns(null, null, "uspGetBillOfMaterials", null);
      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();
   }
}

Vea también

Referencia

SQLServerDatabaseMetaData Class

Conceptos

SQLServerDatabaseMetaData Methods
SQLServerDatabaseMetaData Members