SQLFetch

Make the result cursor of a statement handle is positioned to the next location. The cursor is located on the next record.

Syntax

SQLRETURN SQLFetch (SQLHSTMT aStmt)

Arguments

Table. Arguments

Type Name of Argument Input/Output Description
SQLHSTMT aStmt Input Statement handle

Return Values

Table. Return Values

Return Value Description
SQL_SUCCESS Normal termination
SQL_SUCCESS_WITH_INFO Normal termination *Non-fatal error might occurred
SQL_ERROR Abnormal termination *Communication link failure between databases
SQL_INVALID_HANDLE Abnormal termination *Unallocated statement handle
SQL_NO_DATA_FOUND Abnormal termination *Not able to retrieve more results

Diagnostic Codes

Table. Diagnostic Codes

Code Error Description
08S01 Communication link failure Communication link failure between databases

Sample Code Refer to SQLTables for more information.

SQLFreeConnect

It disconnects the connection of the connection handles.

Syntax

SQLRETURN SQL_API SQLFreeConnect (SQLHDBC aDbc)

Arguments

Table. Arguments

Type Name of Argument Input/Output Description
SQLHDBC aDbc Input Connection handle

Return Values

Table. Return Values

Return Value Description
SQL_SUCCESS Normal termination
SQL_ERROR Abnormal termination *Connection handle is suspended.
SQL_INVALID_HANDLE Abnormal termination *Unallocated connection handle

Diagnostic Codes

Table. Diagnostic Codes

Code Error Description
HY010 Function sequence error Connection handle is suspended.

Sample Code

Refer to SQLAllocConnect for more information.

SQLFreeEnv

It frees environment handles.

Syntax

SQLRETURN SQL_API SQLFreeEnv (SQLHENV aEnv)

Arguments

Table. Arguments

Type Name of Argument Input/Output Description
SQLHENV aEnv Input Environment handle

Return Values

Table. Return Values

Return Value Description
SQL_SUCCESS Normal termination
SQL_INVALID_HANDLE Abnormal termination *Unallocated environment handle

Sample Code

Refer to SQLAllocConnect for more information.

SQLFreeHandle

It frees resources associated with a specific environment, connection, statement, or descriptor handle. It can replace SQLFreeEnv, SQLFreeConnect, and SQLFreeStmt.

Syntax

SQLRETURN SQL_API SQLFreeHandle (SQLSMALLINT aHandleType, SQLHANDLE aHandle)

Arguments

Table. Arguments

Type Name of Argument Input/Output Description
SQLSMALLINT aHandleType Input Type of handle
SQLHANDLE aHandle Input Handle

Return Values

Table. Return Values

Return Value Description
SQL_SUCCESS Normal termination
SQL_ERROR Abnormal termination *Unsupported handle type
SQL_INVALID_HANDLE Abnormal termination *Unallocated handle

Diagnostic Codes

Table. Diagnostic Codes

Handle Type Variable Diagnostic Codes
SQL_HANDLE_ENV Refer to SQLFreeEnv.
SQL_HANDLE_DBC Refer to SQLFreeConnect.
SQL_HANDLE_STMT Refer to SQLFreeStmt.

Sample Code

Refer to SQLAllocHandle for more information.

SQLFreeStmt

It frees all resources associated with the statement handle.

Syntax

SQLRETURN SQL_API SQLFreeStmt(SQLHSTMT aStmt, SQLUSMALLINT aOption)

Arguments

Table. Arguments

Type Name of Argument Input/Output Description
SQLHSTMT aStmt Input Statement handle
SQLUSMALLINT aOption Input Option handle

Return Values

Table. Return Values

Return Value Description
SQL_SUCCESS Normal termination
SQL_ERROR Abnormal termination *Communication link failure between databases
SQL_INVALID_HANDLE Abnormal termination *Unallocated statement handle

Diagnostic Codes

Table. Diagnostic Codes

Code Error Description
08S01 Communication link failure Communication link failure between databases

Sample Code

Refer to SQLAllocConnect for more information.

SQLGetConnectAttr

It returns the current setting of a connection attribute.

Syntax

SQLRETURN SQL_API SQLGetConnectAttr (SQLHDBC aDbc,
SQLINTEGER aAttrCode,
SQLPOINTER aValuePtr,
SQLINTEGER aValueMax,
SQLINTEGER *aValueLength)

Arguments

Table. Arguments

Type Name of Argument Input/Output Description
SQLHDBC aDbc Input Connection handle
SQLINTEGER aAttrCode Input Attribute code
SQLPOINTER aValuePtr Output Result value
SQLINTGER aValueMax Input Buffer size of the result value
SQLINTGER aValueLength Output Length of the result value

Table of Attribute Value

Table. Table of Attribute Value

Attribute value Description Data type
SQL_ATTR_CONNECTION_TIMEOUT Waiting time when connecting Integer
SQL_ATTR_PORT_NO Port number to connect Integer

Return Values

Table. Return Values

Return Value Description
SQL_SUCCESS Normal termination
SQL_ERROR Abnormal termination/ Feature not implemented. Attribute code was not valid.
SQL_INVALID_HANDLE Abnormal termination *Unallocated connection handle

Diagnostic Codes

Table. Diagnostic Codes

Code Error Description
HY092 Invalid attribute/option identifier Attribute code was not valid.
HYC00 Optional feature not implemented Feature not implemented.

Sample Code

//gDbc : Assigned connection parameters
SQLGetConnectAttr (gDbc,
SQL_ATTR_ACCESS_MODE,
(SQLPOINTER)&uIntVal,
(SQLINTEGER)sizeof(uIntVal),
NULL);

SQLGetData

It retrieves data for a single column in the result set that the cursor is currently positioned.

Syntax

SQLRETURN SQL_API SQLGetData(SQLHSTMT aStatementHandle,
SQLUSMALLINT aColumnNumber,
SQLSMALLINT aTargetType,
SQLPOINTER aTargetValue,
SQLLEN aBufferLength,
SQLLEN *aStrLen_or_Ind)

Arguments

Table. Arguments

Type Name of Argument Input/Output Description
SQLHSTMT aStatementHandle Input Statement handle
SQLUSMALLINT aColumnNumber Input Column number
SQLSMALLINT aTargetType Input Column type
SQLPOINTER aTargetValue Output Result value
SQLLEN aBufferLength Input Buffer size of the result value
SQLLEN aStrLen_or_Ind Output Length of the result value

Return Values

Table. Return Values

Return Value Description
SQL_SUCCESS Normal termination
SQL_ERROR Abnormal termination *Column number out of range
SQL_INVALID_HANDLE Abnormal termination *Unallocated statement handle

Diagnostic Codes

Table. Diagnostic Codes

Code Error Description
07009 Invalid descriptor index Column number out of range

** Sample Code

char sColumnData[30];
int sColumnLength;
int sColumnNumber = 1;
SQLGetData(gStmt,
sColumnNumber,
SQL_CHAR,
sColumnData,
sizeof(sColumnData),
&sColumnLength);

SQLGetDescField

It returns the current setting or value of a single field of a descriptor record.

Syntax

SQLRETURN SQL_API SQLGetDescField( SQLHDESC aDescriptorHandle,
SQLSMALLINT aRecordNumber,
SQLSMALLINT aFieldIdentifier,
SQLPOINTER aValue,
SQLINTEGER aBufferLength,
SQLINTEGER *aStringLength )

Arguments

Table. Arguments

Type Name of Argument Input/Output Description
SQLHDESC aDescriptorHandle Input Descriptor handle
SQLSMALLINT aRecordNumber Input Line number
SQLSMALLINT aFieldIdentifier Input Attribute handle
SQLPOINTER aValue Output Pointer to the result value
SQLINTEGER aBufferLength Input Buffer size of the result value
SQLINTEGER* aStringLength Output Length of the result value

Return Values

Table. Return Values

Return Value Description
SQL_SUCCESS Normal termination
SQL_ERROR Abnormal termination Unallocated pointer to result values Line number is out of range from the descriptor table. *Descriptor attribute that does not exist.
SQL_INVALID_HANDLE Abnormal termination *Unallocated descriptor handle

Diagnostic Codes

Code Error Description
07009 Invalid descriptor index Invalid line number
HY009 Invalid use of null pointer Unallocated handle to result value
HY091 Invalid descriptor field identifier Invalid descriptor attribute

Sample Code

SQLSMALLINT sDescAllocType;
SQLHDESC aDesc;
SQLGetDescField(sDesc, 0, SQL_DESC_ALLOC_TYPE, &sDescAllocType, 0, 0);

results matching ""

    No results matching ""