ODBC Users` Manual

Add to My manuals
280 Pages

advertisement

ODBC Users` Manual | Manualzz

SQLSpecialColumns

SQLSpecialColumns

SQLSpecialColumns retrieves the following information about columns within a specified table:

The optimal set of columns that uniquely identifies a row in the table.

• Columns that are automatically updated when any value in the row is updated by a transaction.

SQLSpecialColumnsW() as a Unicode string supports same execution as SQLSpecialColumns().

Syntax

SQLRETURN SQLSpecialColumns (

SQLHSTMT stmt,

SQLSMALLINT fColType,

SQLCHAR *szTableQual,

SQLSMALLINT cbTableQual,

SQLCHAR *szTableOwner,

SQLSMALLINT cbTableOwner,

SQLCHAR *szTableName,

SQLSMALLINT cbTableName,

SQLSMALLINT fScope,

SQLSMALLINT fNullable );

Arguments

Data Type

SQLHSTMT

SQLSMALLINT

Argument stmt fColType

In/Out

Input

Input

SQLCHAR *

SQLSMALLINT

SQLCHAR *

SQLSMALLINT

SQLCHAR *

SQLSMALLINT

SQLSMALLINT szTableQual cbTableQual szTableName cbTableName fScope

Input

Input szTableOwner Input cbTable-

Owner

Input

Input

Input

Input

Description

Statement handle

Type of the column to be returned

SQL_BEST_ROWID: Returns the optimal column that uniquely identify the rows in the table by searching column value(s).

Null will be always returned.

The character number of * szTableQual

Schema Name

The character number of *szTableOwner’

The table name. Cannot be a NULL pointer.

The character number of *szTableNam

Not used

ODBC Users’ Manual 158

Data Type

SQLSMALLINT

Argument fNullable

In/Out

Input

SQLSpecialColumns

Description

Not used (Does not allow NULL data because the corresponding columns are returned to the primary keys.)

Return Values

SQL_SUCCESS

SQL_SUCCESS_WITH_INFO

SQL_INVALID_HANDLE

SQL_ERROR

Description

When fColType is SQL_BEST_ROWID, SQLSpecialColumns () returns column(s) that uniquely identify each row in the table. These columns can be used in select-list or Where clause.

SQLSpecialColumns () is used to return these columns because SQLColumns () does not return the columns that are automatically updated when columns or rows are updated by the transaction.

If there are no columns that uniquely identifies each row in the table, SQLSpecialColumns () will return the row set without rows. To subsequently call SQLFetch () on the command syntax, return

SQL_NO_DATA.

When the fact that the database does not support fColType, fScope, and fNullable arguments is stated, SQLSpecialColumns () will return the empty result set.

Columns Returned by SQLSpecialColumns ()

Name

SCOPE 1

COLUMN_NAME 2

No.

DATA_TYPE

TYPE_NAME

COLUMN_SIZE

3

4

5

Data Type

SMALLINT

VARCHAR

(NOT NULL)

SMALLINT

(NOT NULL)

VARCHAR

(NOT NULL)

INTEGER

Description

SQL_SCOPE_SESSION value is fixed to 2.

Column Name.As for the unnamed string, ODBC returns the empty character string.

SQL data type

Character string representing the name of the data type corresponding to DATA_TYPE.

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

159 ODBC Functions

SQLSpecialColumns

Name

BUFFER_LENGTH 6

DECIMAL_DIGITS 7

No.

Data Type

INTEGER

SMALLINT

PSEUDO_COLUM

N

8 SMALLINT

Description

The maximum byte storing the data

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

Maximum digits of the character of binary datatype string. For other data types, NULL will be returned.

Diagnosis

SQLSTATE

08S01

HY009

Description

Communication line failure

Use an invalid pointer (null pointer)

Comments

Communication channel failure before the function processing is completed between the ODBC and the database szTableName is a NULL pointer.

Related Functions

SQLBindCol

SQLColumns

SQLFetch

SQLPrimaryKeys

Example

See: $ALTIBASE_HOME/sample/SQLCLI/demo_meta7.cpp .> if (SQLSpecialColumns(stmt, 0,

NULL, 0,

NULL, 0,

"DEMO_META7", SQL_NTS,

NULL, 0) != SQL_SUCCESS)

{

execute_err(dbc, stmt, "SQLColumns");

SQLFreeStmt(stmt, SQL_DROP);

return SQL_ERROR;

}

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

SQLBindCol(stmt, 3, SQL_C_SSHORT, &DataType, 0, &cbDataType);

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

ODBC Users’ Manual 160

SQLSpecialColumns

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

SQLBindCol(stmt, 6, SQL_C_SLONG, &BufferLength, 0, &cbBufferLength);

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

161 ODBC Functions

advertisement

advertisement

Table of contents