Version: 7.0.0

SQLGetData ​

Function ​

Returns data from a specified column in the result set. It can be called multiple times to retrieve variable-length data in parts.

Prototype ​

c
SQLRETURN SQLGetData(SQLHSTMT        StatementHandle,
                     SQLUSMALLINT    Col_or_Param_Num,
                     SQLSMALLINT     TargetType,
                     SQLPOINTER      TargetValuePtr,
                     SQLLEN          BufferLength,
                     SQLLEN          *StrLen_or_IndPtr);

Parameters ​

Table 1 SQLGetData parameters

Keyword

Description

StatementHandle

Statement handle, obtained through SQLAllocHandle.

Col_or_Param_Num

Column number from which data is returned. Result set columns are numbered in ascending order starting from 1.

TargetType

Type identifier of the C data type in the TargetValuePtr buffer. If it is SQL_C_DEFAULT, the driver selects the default data type based on the source SQL data type.

TargetValuePtr

Output Parameter: Pointer to the buffer where the returned data is stored.

BufferLength

Length of the buffer pointed to by TargetValuePtr.

StrLen_or_IndPtr

Output Parameter: Pointer to a buffer in which to return the length or identifier value.

Return Values ​

  • SQL_SUCCESS: The call is successful.

  • SQL_SUCCESS_WITH_INFO: Some warning information is present.

  • SQL_ERROR: Column data failed to be fetched from the result set.

  • SQL_NO_DATA: The SQL statement does not return a result set.

  • SQL_INVALID_HANDLE: The input handle is invalid.

Example ​

See: Example