16.9.8 SQLGetData
- Organization of this subsection
(1) Function
This ODBC function acquires data for a single column in the result set.
(2) Format
SQLRETURN SQLGetData ( SQLHSTMT StatementHandle, /* In */ SQLUSMALLINT ColumnNumber, /* In */ SQLSMALLINT TargetType, /* In */ SQLPOINTER TargetValuePtr, /* Out */ SQLLEN BufferLength, /* In */ SQLLEN * StrLen_or_IndPtr /* Out */ )
(3) Arguments
- StatementHandle
-
Specifies a statement handle.
- ColumnNumber
-
Specifies the number of the column whose data is to be acquired.
The column numbering begins with 1 because HADB does not support bookmarks.
- TargetType
-
Specifies the C data type identifier of the area pointed to by TargetValuePtr or specifies SQL_C_DEFAULT. If SQL_C_DEFAULT is specified, the driver assumes the default C data type.
- TargetValuePtr
-
Specifies a pointer to the area that is to receive the column's data.
- BufferLength
-
Specifies the length (in bytes) of the area pointed to by TargetValuePtr.
- StrLen_or_IndPtr
-
Specifies a pointer to the area in which the data length or indicator is returned by the HADB ODBC driver.
The HADB ODBC driver returns the data length of the indicator.
If the column data is a null value, the return value is SQL_NULL_DATA.
(4) Return value
This ODBC function returns SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_NO_DATA, SQL_ERROR, or SQL_INVALID_HANDLE.
(5) SQLSTATE
This ODBC function returns one of the following SQLSTATE values:
SQLSTATE |
Description |
Remarks |
Returned |
---|---|---|---|
01000 |
General warning |
-- |
N |
01004 |
Character string data was right-truncated |
The buffer pointed to by the TargetValuePtr buffer is not large enough to store the data for the column specified by ColumnNumber. The function returns SQL_SUCCESS_WITH_INFO. |
Y |
01S07 |
Fractional truncation |
The fractional part of the numeric value was truncated. For time, time stamp, and interval data types that contain a time component, the fractional part of the time was truncated. The function returns SQL_SUCCESS_WITH_INFO. |
Y |
01S51 |
Code replacement occurred during conversion of character encoding |
A character code that cannot be converted was detected and then replaced with the specified character. The function returns SQL_SUCCESS_WITH_INFO. |
Y |
07006 |
Restricted data type attribute violation |
A data value in the column in the result set cannot be converted to the C data type specified by TargetType. |
Y |
07009 |
Invalid descriptor index |
The column number specified in ColumnNumber does not exist. |
Y |
08S01 |
Communication link failure |
-- |
N |
22002 |
Required indicator variable not supplied |
StrLen_or_IndPtr is a null pointer and NULL data was acquired. |
Y |
22003 |
Numeric value out of range |
The integer part of the numeric value (numeric value or character string) was deleted. |
N |
22007 |
Invalid datetime format |
A character column was bound to a date, time, or time stamp C structure, but the value in the column is an invalid date, time, or time stamp. |
Y |
22012 |
Division by zero |
A value obtained from an arithmetic expression resulting in division by zero was returned. |
N |
22015 |
Interval field overflow |
-- |
N |
22018 |
Invalid character value for cast specification |
Y |
|
24000 |
Invalid cursor status |
A cursor was open on StatementHandle and SQLFetch was called, but the cursor was positioned before the beginning of the result set or after the end of the result set. |
Y |
5C002 |
Character encoding conversion error |
-- |
Y |
5C037 |
Data format error |
Y |
|
5C038 |
Data conversion error |
There is an error in the acquired result data or in the specification of the receiving area. |
Y |
HY000 |
General error |
-- |
N |
HY001 |
Memory allocation error |
The memory required to execute or complete the function has not been allocated for the HADB ODBC driver. |
Y |
HY003 |
Invalid application buffer data type |
-- |
Y |
HY008 |
Operation cancelled |
N |
|
HY009 |
Invalid use of null pointer |
Null pointers were specified for both TargetValuePtr and StrLen_or_IndPtr. |
Y |
HY010 |
Function sequence error |
-- |
Y |
HY013 |
Memory management error |
Y |
|
HY090 |
Invalid string or buffer length |
The following conditions are both satisfied:
|
Y |
HY104 |
Invalid precision or scale value |
-- |
Y |
HY109 |
Invalid cursor position |
-- |
N |
HYC00 |
Optional feature not implemented |
The driver does not support the conversion specified by the combination of TargetType and the SQL data type of the corresponding column. |
Y |
HYT00 |
Timeout expired |
-- |
N |
- Legend:
-
Y: This SQLSTATE might be returned by the HADB ODBC driver.
N: This SQLSTATE is not returned by the HADB ODBC driver.
--: None
(6) Notes
This ODBC function does not support the following functions:
-
Acquiring variable-length data in segments
-
Limitations on the maximum length of data that can be returned