ODBC Users` Manual

Add to My manuals
280 Pages

advertisement

ODBC Users` Manual | Manualzz

SQLProcedureColumns

SQLProcedureColumns

SQLProcedureColumns returns the list of input and output parameters, as well as the columns that make up the result set for the specified procedures. The driver returns the information as a result set on the specified statement.

SQLProcedureColumnsW() as a Unicode string supports same execution as

SQLProcedureColumns().

Syntax

SQLRETURN SQLProcedureColumns (

SQLHSTMT stmt,

SQLCHAR *cName,

SQLSMALLINT cNameLength,

SQLCHAR *sName,

SQLSMALLINT sNameLength,

SQLCHAR *pName,

SQLSMALLINT pNameLength,

SQLCHAR *colName,

SQLSMALLINT colNameLength );

Arguments

Data Type

SQLHSTMT

SQLCHAR *

SQLSMALLINT

SQLCHAR *

SQLSMALLINT

SQLCHAR *

Argument In/Out stmt cName

Input

Input cNameLength Input sName Input sNameLength Input pName Input

SQLSMALLINT

SQLCHAR *

SQLSMALLINT pNameLength Input colName colName-

Length

Input

Input

Description

Statement handle

Procedure Catalog Name

The character number of *cName

Procedure Schema Name

Length of character string of *sName

Procedure name. Cannot be a NULL pointer. pName must not include the character string search pattern.

Character string of *pName

Column Name

Character string of *colName

Return Values

SQL_SUCCESS

133 ODBC Functions

SQLProcedureColumns

SQL_SUCCESS_WITH_INFO

SQL_INVALID_HANDLE

SQL_ERROR

Description

This function is used before a statement is executed to retrieve the procedure parameters and the columns that form the result sets returned by the procedure.

SQLProcedureColumns () returns the results in the standard result set sorted in order by

PROCEDURE_CAT, PROCEDURE_SCHEM, PROCEDURE_NAME, and COLUMN_TYPE. The column names will be returned for each procedure in the following order: Name of returned value, each parameter names to call the procedures (or calling order), and column names of the result set returned by the procedure (or column order.)

An application must bind the unique columns which contains the ODBC driver information to the last data of the result set.

Columns Returned by SQLProcedureColumns ()

Name

PROCEDURE_CAT

PROCEDURE _SCHEM

PROCEDURE _NAME

COLUMN_NAME

COLUMN_TYPE

DATA_TYPE

TYPE_NAME

1

2

No.

Data Type

VARCHAR

VARCHAR

3

Description

Returns NULL always

Procedure schema name; NULL if not applicable to the database

Procedure name

4

VARCHAR

(NOT NULL)

VARCHAR

(NOT NULL)

5

6

SMALLINT

(NOT NULL)

Procedure column name. The driver returns an empty string for a procedure column that does not have a name.

Defines the procedure column as a parameter or a result set column:.SQL_PARAM_INOUT: The procedure column is the input parameter.SQL_PARAM_INOUT_OUTPUT: The procedure column is the input/output parameters.SQL_PARAM_OUTPUT: The procedure column is the output parameter.

SQL data type

7

SMALLINT

(NOT NULL)

VARCHAR

(NOT NULL)

Name of the data type corresponding to the database

ODBC Users’ Manual 134

SQLProcedureColumns

Name

COLUMN_SIZE

BUFFER_LENGTH

DECIMAL_DIGITS

NUM_PREC_RADIX

NULLABLE

REMARKS

COLUMN_DEF

SQL_DATA_TYPE

SQL_DATETIME_SUB

CHAR_OCTET_LENGTH

ORDINAL_POSITION

IS_NULLABLE

8

No.

9

10

11

12

13

14

15

16

17

18

19

Data Type Description

INTEGER

INTEGER

SMALLINT

SMALLINT

SMALLINT

(NOT NULL)

VARCHAR

VARCHAR

Column Size. NULL will be returned when the column size is not proper.

The maximum byte storing the data

The NULL will return the data type that cannot apply the decimal points of the string and the decimal points.

In case of the numeric data type 10: For

COLUMN_SIZE and DECIMAL_DIGIT, decimal digits allowable in this string is be given. For example, DECIMAL(12,5) string can return NUM_PREC_RADIX 10,

COLUMN_SIZE 12, and DECIMAL_DIGITS

5.

SQL_NO_NullS when the procedure column does not allow NULL value, or

SQL_Nullable when NULL is allowed.

Description of the procedure column

The default value of the column. If NULL was specified as the default value, this column is the word NULL, not enclosed in quotation marks. If the default value cannot be represented without truncation, this column contains TRUNCATED, with no enclosing single quotation marks. If no default value was specified, this column is NULL.The value of COLUMN_DEF can be used in generating a new column definition, except when it contains the value TRUNCATED

SQL data type SMALLINT

(NOT NULL)

SMALLINT

INTEGER

INTEGER (NOT

NULL)

VARCHAR

The subtype code for datetime and interval data types. For other data types, this column returns a NULL.

Maximum digits of the character string or binary data-type string.

Location of the order of the parameters in the procedure definition (starting with 1)

NO : When the string does not contain the NULL:YES : When the string contain the NULL:

135 ODBC Functions

SQLProcedureColumns

Diagnosis

SQLSTATE

HY000

HY009

Description Comments

General error

Invalid Arguments used (null pointer).

CName is a NULL pointer

Related Functions

SQLBindCol

SQLFetch

SQLProcedures

Example

See: $ALTIBASE_HOME/sample/SQLCLI/demo_meta6.cpp

if (SQLProcedureColumns(stmt,

NULL, 0,

NULL, 0,

"DEMO_META6_PROC", SQL_NTS,

NULL, 0) != SQL_SUCCESS)

{

execute_err(dbc, stmt, "SQLProcedureColumns");

SQLFreeStmt(stmt, SQL_DROP);

return SQL_ERROR;

}

SQLBindCol(stmt, 1, SQL_C_CHAR, szCatalog, STR_LEN,&cbCatalog);

SQLBindCol(stmt, 2, SQL_C_CHAR, szSchema, STR_LEN, &cbSchema);

SQLBindCol(stmt, 3, SQL_C_CHAR, szProcName, STR_LEN,&cbProcName);

SQLBindCol(stmt, 4, SQL_C_CHAR, szColumnName, STR_LEN, &cbColumnName);

SQLBindCol(stmt, 5, SQL_C_SSHORT, &ColumnType, 0, &cbColumnType);

SQLBindCol(stmt, 7, SQL_C_CHAR, szTypeName, STR_LEN, &cbTypeName);

SQLBindCol(stmt, 8, SQL_C_SLONG, &ColumnSize, 0, &cbColumnSize);

SQLBindCol(stmt, 10, SQL_C_SSHORT, &DecimalDigits, 0, &cbDecimalDigits);

SQLBindCol(stmt, 11, SQL_C_SSHORT, &NumPrecRadix, 0, &cbNumPrecRadix);

SQLBindCol(stmt, 18, SQL_C_SLONG, &OrdinalPosition, 0, &cbOrdinalPosition);

ODBC Users’ Manual 136

advertisement

advertisement

Table of contents