Core function
Assign an ESL variable and type conversion for a column in a result set.
EDSBindCol(HSTMT_IV, ICOL_IV, ETYPE_IV, VALUE_SV |VALUE_IV |VALUE_FV, MAXBYTES_IV, NUMBYTES_IV )
•HSTMT_IV An input integer value indicating the statement handle.
•ICOL_IV An input integer value indicating the column number of result data, ordered sequentially left to right, starting at 1.
•ETYPE_IV An input integer value indicating the data type for the result data. ETYPE_IV must contain one of the following values:
EDS_STRING
EDS_INT
EDS_FLOAT
•VALUE_SV|VALUE_IV|VALUE_FV The ESL variable of the data type corresponding to ETYPE_IV that will be updated with the value from the database.
•MAXBYTES_IV An input integer value that contains the maximum number of bytes to store in the VALUE parameter. This parameter is used for EDS_STRING only. (It is ignored for EDS_INT and EDS_FLOAT.)
•NUMBYTES_IV An input integer reference value that, after each EDSFetch operation, returns either the actual number of bytes transferred to the VALUE parameter or EDS_NULL_DATA.
Description
EDS provides two ways to retrieve data:
•EDSBindCol links a buffer to a query result for a column that contains typical character and numeric data.
•EDSGetData retrieves a column that contains a large data value.
EDS coordinates interaction between EDSBindCol, EDSFetch, query processing, and EDSGetData (if the driver supports EDSGetData).
For the column specified, EDSBindCol assigns the following variables and data types:
•An ESL variable that will receive the contents of a column of data
•An ESL variable that will receive the actual length of the column of data returned by the fetch operation
•Data conversion
Your application defines variables and can use EDSBindCol to associate these variables with result columns. You must call EDSBindCol prior to fetching data. For each bound column, EDS updates the variable at fetch time and stores the actual number of bytes in the result column in NUMBYTES_IV. Each time EDSFetch is called, EDS places the next row of the result set into the variables specified in previous calls to EDSBindCol for each column. If the data value for a column is null, EDS sets NUMBYTES_IV to EDS_NULL_DATA. If truncation occurs, EDS returns EDS_SUCCESS_WITH_INFO at fetch time.
To rebind, call EDSBindCol after fetching zero or more rows of data. To unbind all bound columns, call EDSFreeStmt with the EDS_UNBIND option.
EDSGetData is an alternative function for retrieving data. Unlike EDSBindCol, which specifies an ESL variable that is filled implicitly when EDSFetch or EDSExtendedFetch is called, EDSGetData retrieves a single data value for the current row fetched. EDSGetData retrieves long values from a column in portions. In developing your application, you can choose to bind every column using EDSBindCol; to do no binding and retrieve data values using EDSGetData only; or to use a combination of the two.
Return Values
EDSBindCol returns EDS_SUCCESS, EDS_INVALID_HANDLE, or EDS_ERROR.
When EDSBindCol returns EDS_ERROR, you can obtain an associated SQLSTATE value with more specific information by calling EDSError. The following table lists each possible SQLSTATE value and explains each one in the context of the command EDSBindCol.
SQL STATE |
Error |
Description |
IM001 |
Driver does not support the function |
The driver associated with the statement handle does not support the. function |
S1000 |
General error |
An error occurred for which there was no specific SQLSTATE and for which no implementation-specific SQLSTATE was defined. The error message returned by EDSError in the argument ERRORTEXT describes the error and its cause. |
S1001 |
Memory allocation failure |
The driver was unable to allocate memory required to support execution or completion of the function. |
S1002 |
Invalid column number |
The value specified for the argument ICOL_IV was 0. The value specified for the argument ICOL_IV exceeded the maximum number of columns supported by the data source. |
S1003 |
Program type out of range |
The argument ETYPE_IV was not a valid data type. |
S1009 |
Invalid argument value |
The VALUE argument was a null value. |
S1010 |
Function sequence error |
An asynchronously executing function (not this one) was called for the statement handle and was still executing when this function was called. |
See Also
EDSNumResultCols determines the number of columns in a result set.
EDSDescribeCol retrieves information about a result column.
EDSFetch retrieves row data.
EDSGetData retrieves column data in a long data type.