Retrieving results and information about results
These functions retrieve results and their information:
-
SQLRowCount
This retrieves the number of rows that are affected by an insert, update, or delete request.
odbc SQLRowCount $hstmt RowCountPtr
-
SQLNumResultCols
This retrieves the number of columns in a result set.
odbc SQLNumResultCols $hstmt ColumnCountPtr
-
SQLDescribeCol
This retrieves five parameters describing a column in a result set.
odbc SQLDescribeCol $hstmt 1 ColumnName 32 \ NameLengthPtr DataTypePtr ColumnSizePtr \ DecimalDigitsPtr NullablePtr
-
SQLColAttribute
This retrieves descriptor information for a column in a result set.
odbc SQLColAttribute $hstmt 1 \ SQL_DESC_CASE_SENSITIVE CharacterAttributePtr \ 16 StringLengthPtr NumericAttributePtr
-
SQLBindCol
This assigns storage for a column in a result set.
odbc SQLBindCol $hstmt 1 SQL_C_SLONG id 0 idlen odbc SQLBindCol $hstmt 2 SQL_C_DOUBLE dTagOut 0 dTaglen odbc SQLBindCol $hstmt 3 SQL_C_CHAR nameOut 32 namelen
-
SQLFetch
This retrieves a row of data from a result set.
odbc SQLFetch $hstmt
-
SQLFetchScroll
This retrieves a rowset of data and absolute, relative, or bookmarked position in the rowset.
odbc SQLFetchScroll $hstmt SQL_FETCH_NEXT 0
If the statement attributes are set before an invocation to SQLFetch or SQLFetchScroll during the retrieval, then rgfRowStatus is set to a Tcl array. This array is indexed starting from "0" with the number of elements equal to the number of rows in the rowset. This number is specified with the SQL_ROW_ARRAY_SIZE attribute of SQLSetStmtAttr.
odbc SQLSetStmtAttr $hstmt SQL_ATTR_ROW_STATUS_PTR\ rgfRowStatus 0
-
SQLGetData
This retrieves data from a single unbound column in the current row. The TargetType parameter can be coded as for SQLBindCol.
odbc SQLGetData $hstmt 1 SQL_C_CHAR nameOut 50 \ StrLen_or_IndPtr1 odbc SQLGetData $hstmt 2 SQL_C_SSHORT dTagOut 15 \ StrLen_or_IndPtr2 odbc SQLGetData $hstmt 3 SQL_C_CHAR idOut 10 \ StrLen_or_IndPtr3 odbc SQLSetPos $hstmt 4 SQL_POSITION \ SQL_LOCK_NO_CHANGE odbc SQLSetPos $hstmt 0 SQL_REFRESH \ SQL_LOCK_NO_CHANGE odbc SQLSetPos $hstmt 2 SQL_UPDATE \ SQL_LOCK_NO_CHANGE odbc SQLSetPos $hstmt 3 SQL_DELETE \ SQL_LOCK_NO_CHANGE odbc SQLSetPos $hstmt 2 SQL_ADD SQL_LOCK_NO_CHANGE
-
SQLMoreResults
This retrieves multiple result sets.
odbc SQLMoreResults $hstmt
-
SQLGetDiagRec and SQLGetDiagField
This retrieves ODBC status information.
These examples show how to get information on a particular error that is related to a connection handle or a statement handle, respectively.
odbc SQLGetDiagRec SQL_HANDLE_DBC $hdbc 1 SqlState \ NativeError MessageText 511 TextLength odbc SQLGetDiagRec SQL_HANDLE_STMT $hstmt 1 \ SqlState NativeError MessageText 511 TextLength
This example shows how to get the field value of an error that is related to a connection handle.
odbc SQLGetDiagField SQL_HANDLE_DBC $hdbc 1 \ SQL_DIAG_SERVER_NAME DiagInfoPtr 256 \ StringLengthPtr