advertisement
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
- 14 About This Manual
- 14 Target Users
- 14 Software Environment
- 14 Organization
- 15 Convention
- 17 Related Resource
- 17 Online Manual
- 18 Altibase Welcomes Your Opinions!
- 20 Open Database Connectivity
- 20 Backgrounds of the ODBC
- 20 ODBC versus Embedded C/C++ Programming
- 20 Groups of ODBC Functions
- 22 Using the ODBC
- 22 Basic Usages
- 22 Initializing Handles
- 23 Processing of Transactions
- 24 Release Handle
- 24 Managing Diagnosis Messages
- 24 Restriction
- 25 Using ODBC
- 25 Using UNIX ODBC versus Using Windows ODBC
- 27 Basic Programming Steps
- 28 Step 1: Connecting to a Database
- 28 Step 2: Initializing an application Status
- 28 Step 3: Executing an SQL statements
- 29 Step 4a: Fetch the Results
- 29 Step 4b: Fetch the Affected Row Count
- 30 Step 5: Commit/Rollback a Transaction
- 30 Step 6: Disconnect from the Altibase Database
- 31 Summary of ODBC Functions
- 36 SQLAllocConnect
- 36 Syntax
- 36 Arguments
- 36 Return Values
- 36 Description
- 37 Diagnosis
- 37 Related Functions
- 37 Example
- 38 SQLAllocEnv
- 38 Syntax
- 38 Arguments
- 38 Return Values
- 38 Description
- 38 Related Functions
- 39 Example
- 40 SQLAllocHandle
- 40 Syntax
- 40 Arguments
- 40 Return Values
- 41 Description
- 42 Diagnosis
- 42 Related Functions
- 42 Example
- 43 SQLAllocStmt
- 43 Syntax
- 43 Arguments
- 43 Return Values
- 43 Description
- 44 Diagnosis
- 44 Related Functions
- 44 Example
- 45 SQLBindCol
- 45 Syntax
- 45 Arguments
- 46 Return Values
- 46 Description
- 47 Diagnosis
- 47 Related Functions
- 47 Example
- 49 SQLCloseCursor
- 49 Syntax
- 49 Arguments
- 49 Return Value
- 49 Description
- 49 Diagnostics
- 50 Related Function
- 51 SQLBindParameter
- 51 Syntax
- 51 Arguments
- 52 Return Values
- 53 Description
- 56 Example
- 57 Constraints
- 57 Diagnosis
- 57 Related Functions
- 57 Example
- 60 SQLColAttribute
- 60 Syntax
- 60 Arguments
- 61 Return Values
- 61 Description
- 62 Diagnosis
- 63 Related Functions
- 63 Example
- 64 SQLColumns
- 64 Syntax
- 64 Arguments
- 64 Return Values
- 65 Description
- 66 Diagnosis
- 66 Related Functions
- 67 Example
- 68 SQLConnect
- 68 Syntax
- 68 Arguments
- 68 Return Values
- 69 Description
- 69 Diagnosis
- 69 Related Functions
- 70 SQLDescribeCol
- 70 Syntax
- 70 Arguments
- 71 Return Values
- 71 Description
- 71 Diagnosis
- 72 Related Functions
- 72 Example
- 73 SQLDescribeParam
- 73 Syntax
- 73 Arguments
- 73 Return Values
- 74 Description
- 74 Diagnosis
- 74 Related Functions
- 74 Example
- 76 SQLDisconnect
- 76 Syntax
- 76 Arguments
- 76 Return Values
- 76 Description
- 77 Diagnosis
- 77 Related Functions
- 77 Example
- 78 SQLDriverConnect
- 78 Syntax
- 78 Arguments
- 79 Return Values
- 79 Description
- 80 Restriction
- 81 Diagnosis
- 81 Related Functions
- 82 Example
- 83 SQLEndTran
- 83 Syntax
- 83 Arguments
- 83 Return Values
- 83 Description
- 84 Diagnosis
- 84 Related Functions
- 84 Example
- 85 SQLError
- 85 Syntax
- 85 Arguments
- 85 Return Values
- 86 Description
- 86 Example
- 87 SQLExecDirect
- 87 Syntax
- 87 Arguments
- 87 Return Values
- 87 Description
- 88 Diagnosis
- 88 Related Functions
- 88 Example
- 89 SQLExecute
- 89 Syntax
- 89 Arguments
- 89 Return Values
- 89 Description
- 90 Diagnosis
- 90 Related Functions
- 91 Example
- 92 SQLFetch
- 92 Syntax
- 92 Arguments
- 92 Return Values
- 92 Description
- 94 Diagnosis
- 95 Related Functions
- 95 Example
- 96 SQLFetchScroll
- 96 Syntax
- 96 Arguments
- 96 Return Values
- 96 Description
- 97 Diagnosis
- 97 Related Functions
- 97 Example
- 98 SQLForeignKeys
- 98 Syntax
- 98 Arguments
- 99 Return Values
- 99 Description
- 101 Diagnosis
- 101 Related Functions
- 101 Example
- 102 SQLFreeConnect
- 102 Syntax
- 102 Arguments
- 102 Return Values
- 102 Description
- 102 Related Functions
- 102 Example
- 104 SQLFreeEnv
- 104 Syntax
- 104 Arguments
- 104 Return Values
- 104 Description
- 104 Related Functions
- 104 Example
- 105 SQLFreeHandle
- 105 Syntax
- 105 Arguments
- 105 Return Values
- 105 Description
- 106 Diagnosis
- 106 Related Functions
- 106 Example
- 107 SQLFreeStmt
- 107 Syntax
- 107 Arguments
- 107 Return Values
- 107 Description
- 108 Diagnosis
- 108 Related Functions
- 108 Example
- 109 SQLGetConnectAttr
- 109 Syntax
- 109 Arguments
- 109 Return Values
- 110 Description
- 110 Diagnosis
- 111 Related Functions
- 111 Example
- 112 SQLGetData
- 112 Syntax
- 112 Arguments
- 113 Return Values
- 113 Description
- 114 Diagnosis
- 114 Related Functions
- 115 Example
- 116 SQLGetDescField
- 116 Syntax
- 116 Arguments
- 116 Return Value
- 117 Description
- 117 Diagnostics
- 117 Related Function
- 118 SQLGetDescRec
- 118 Syntax
- 118 Arguments
- 118 Return Value
- 119 Description
- 119 Diagnostics
- 119 Related Function
- 120 SQLGetDiagField
- 120 Syntax
- 120 Arguments
- 121 Result Value
- 121 Description
- 121 Related Function
- 122 SQLGetDiagRec
- 122 Syntax
- 122 Argument
- 122 Return Value
- 123 Description
- 123 Related Function
- 124 SQLGetEnvAttr
- 124 Syntax
- 124 Argument
- 124 Return Value
- 124 Description
- 125 Diagnosis
- 125 Related Function
- 126 SQLGetFunctions
- 126 Syntax
- 126 Argument
- 126 Return Value
- 126 Description
- 127 Diagnostics
- 127 Related Function
- 128 SQLGetInfo
- 128 Syntax
- 128 Arguments
- 128 Return Values
- 129 Description
- 129 Diagnosis
- 130 SQLGetPlan
- 130 Syntax
- 130 Arguments
- 130 Returned Values
- 130 Description
- 130 Related Function
- 130 Example
- 131 SQLGetStmtAttr
- 131 Syntax
- 131 Arguments
- 132 Return Values
- 132 Description
- 132 Diagnosis
- 132 Related Functions
- 132 Example
- 133 SQLGetTypeInfo
- 133 Syntax
- 133 Arguments
- 133 Return Values
- 133 Description
- 133 Diagnosis
- 134 Related Functions
- 134 Example
- 136 SQLMoreResult
- 136 Syntax
- 136 Arguments
- 136 Result Values
- 136 Description
- 136 Related Function
- 137 SQLNativeSql
- 137 Syntax
- 137 Argument
- 137 Return Value
- 137 Description
- 138 Diagnosis
- 138 Example
- 139 SQLNumParams
- 139 Syntax
- 139 Arguments
- 139 Return Values
- 139 Description
- 139 Diagnosis
- 139 Related Functions
- 140 Example
- 141 SQLNumResultCols
- 141 Syntax
- 141 Arguments
- 141 Return Values
- 141 Description
- 142 Diagnosis
- 142 Related Functions
- 142 Example
- 143 SQLParamData
- 143 Syntax
- 143 Argument
- 143 Return Value
- 143 Description
- 143 Diagnosis
- 144 Related Function
- 145 SQLPrepare
- 145 Syntax
- 145 Arguments
- 145 Return Values
- 145 Description
- 146 Diagnosis
- 146 Related Functions
- 146 Example
- 148 SQLPrimaryKeys
- 148 Syntax
- 148 Arguments
- 148 Return Values
- 149 Description
- 149 Diagnosis
- 149 Related Functions
- 150 Example
- 151 SQLProcedureColumns
- 151 Syntax
- 151 Arguments
- 151 Return Values
- 152 Description
- 154 Diagnosis
- 154 Related Functions
- 154 Example
- 155 SQLProcedures
- 155 Syntax
- 155 Arguments
- 155 Return Values
- 156 Description
- 157 Diagnosis
- 157 Related Functions
- 157 Example
- 158 SQLPutData
- 158 Syntax
- 158 Argument
- 158 Return Value
- 158 Description
- 158 Diagnosis
- 159 Related Function
- 160 SQLRowCount
- 160 Syntax
- 160 Arguments
- 160 Return Values
- 160 Description
- 161 Diagnosis
- 161 Related Functions
- 161 Example
- 162 SQLSetConnectAttr
- 162 Syntax
- 162 Arguments
- 162 Return Values
- 163 Description
- 163 Diagnosis
- 163 Related Functions
- 164 Example
- 165 SQLSetDescField
- 165 Syntax
- 165 Argument
- 165 Return Value
- 165 Description
- 166 Diagnosis
- 166 Related Function
- 167 SQLSetEnvAttr
- 167 Syntax
- 167 Arguments
- 167 Return Values
- 167 Description
- 168 Diagnosis
- 168 Related Functions
- 169 SQLSetStmtAttr
- 169 Syntax
- 169 Arguments
- 171 Return Values
- 171 Description
- 174 Diagnosis
- 174 Example
- 176 SQLSpecialColumns
- 176 Syntax
- 176 Arguments
- 177 Return Values
- 177 Description
- 178 Diagnosis
- 178 Related Functions
- 178 Example
- 180 SQLStatistics
- 180 Syntax
- 180 Arguments
- 180 Return Values
- 181 Description
- 182 Diagnosis
- 183 Related Functions
- 183 Example
- 184 SQLTablePrivileges
- 184 Syntax
- 184 Arguments
- 184 Return Values
- 185 Description
- 186 Diagnosis
- 186 Related Functions
- 186 Example
- 187 SQLTables
- 187 Syntax
- 187 Arguments
- 187 Return Values
- 188 Description
- 189 Diagnosis
- 189 Related Functions
- 189 Example
- 191 SQLTransact
- 191 Syntax
- 191 Arguments
- 191 Return Values
- 191 Description
- 192 Example
- 194 LOB Data Types
- 195 Function Overview
- 196 SQLBindFileToCol
- 196 Syntax
- 196 Arguments
- 197 Result Values
- 197 Description
- 198 Diagnosis
- 198 Related Functions
- 198 Examples
- 201 SQLBindFileToParam
- 201 Syntax
- 201 Arguments
- 202 Result Values
- 202 Description
- 203 Diagnosis
- 203 Related Functions
- 203 Examples
- 206 SQLGetLobLength
- 206 Syntax
- 206 Arguments
- 206 Result Values
- 206 Description
- 207 Diagnosis
- 207 Related Functions
- 208 Example
- 209 SQLGetLob
- 209 Syntax
- 209 Arguments
- 210 Result Values
- 210 Description
- 210 Diagnosis
- 210 Related Functions
- 211 Example
- 213 SQLPutLob
- 213 Syntax
- 213 Arguments
- 214 Result Values
- 214 Description
- 214 Diagnosis
- 214 Related Functions
- 215 Examples
- 219 SQLFreeLob
- 219 Syntax
- 219 Arguments
- 219 Result Values
- 219 Description
- 220 Diagnosis
- 220 Related Functions
- 220 Example
- 221 Programing Considerations
- 221 Multithreading
- 221 Statement Handles
- 221 Binding Parameters
- 222 Transaction Commit Mode
- 222 Using SQLFreeStmt() function
- 222 Sample of Simple Basic Program
- 228 Sample of Using Metadata
- 235 Example of Procedure test Program
- 239 SQL Data Types
- 240 C Data Types
- 242 Converting SQL Data into C Data Types
- 243 Converting C Data into SQL Data types
- 245 ODBC Error Codes
- 247 Database Connection-related Error Codes
- 248 Network-related Error Codes
- 248 Statement State Transition-related Errors
- 250 SQLAllocHandle
- 250 SQLBindCol
- 250 SQLBindParameter
- 250 SQLColumns, SQLGetTypeInfo, SQLPrimaryKeys, SQLProcedureColumns, SQLProcedures, SQLStatistics, SQLTables
- 251 SQLConnect
- 251 SQLDisconnect
- 251 See SQLDriverConnect: SQLConnect
- 251 SQLExecDirect
- 252 SQLExecute
- 252 SQLFetch
- 252 SQLFreeHandle
- 252 SQLFreeStmt
- 253 SQLGetData
- 253 SQLGetTypeInfo: See SQLColumns.
- 253 SQLNumResultCols
- 253 SQLPrepare
- 253 SQLPrimaryKeys: See SQLColumns.
- 254 SQLProcedureColumns: See SQLColumns.
- 254 SQLProcedures: See SQLColumns.
- 254 SQLSetConnectAttr
- 254 SQLSetEnvAttr
- 254 SQLSetStmtAttr
- 255 SQLStatistics: See SQLColumns.
- 255 SQLTables: See SQLColumns.
- 255 State Transition Tables
- 257 Interface Conformance Levels
- 257 Function Conformance Level
- 261 Data Type
- 261 SQLCHAR, SQLSCHAR
- 261 SQL_BIT, SQL_VARBIT
- 265 SQL_NIBBLE
- 267 SQL_BYTE
- 269 DATE : SQL_TYPE_TIMESTAMP
- 269 LOB
- 273 Other Changes
- 273 SQLCloseCursor
- 274 SQLBindParameter - ColumnSize Argument
- 274 SQLBindParameter – StrLen_or_IndPtr Argument
- 274 SQLPutData(), SQLParamData()
- 276 Limitation on ALTER SESSION statements
- 277 SQLRowCount(), SQLMoreResults() functions
- 278 Unlimited Array Execute, Array Fetch
- 278 Unavailable Properties