Skip to content

SQLGetLobLength2

SQLGetLobLength2#

SQLGetLobLength gets the length of the LOB pointed by the LOB locator obtained during the current transaction.

Syntax#

SQLRETURN SQLGetLobLength2(SQLHSTMT      stmt,
                           SQLUBIGINT    locator,
                           SQLSMALLINT   locatorCType,
                           SQLUINTEGER  *valueLength,
                           SQLLEN       *indicator);

Arguments#

Data Type Argument In/Output Description
SQLHSTMT stmt Input A handle for the found results.
SQLUBIGINT locator Input LOB Locator
SQLSMALLINT locatorCType Input The C data type of A LOB locator. It can have the following values:
- SQL_C_BLOB_LOCATOR
- SQL_C_CLOB_LOCATOR
SQLUINTEGER * valueLength Output It stores the length of a LOB.
The buffer pointed to by the pointer returns the data length.
SQLLEN * indicator Output Indicates whether the LOB data is NULL.
- SQL_NULL_DATA: The LOB Data is NULL.
- 0: The LOB Data is not NULL (includes both Empty LOB or non-empty LOB data).

Return Values#

SQL_SUCCESS
SQL_SUCCESS_WITH_INFO
SQL_INVALID_HANDLE
SQL_ERROR

Description#

This function retrieves the length of the LOB referenced by a LOB locator and is used to determine whether the LOB data is NULL or an Empty LOB.

The length of the LOB is returned through the valueLength parameter, and the indicator parameter is used to determine whether the LOB is NULL or Empty.

  • If indicator returns SQL_NULL_DATA, the LOB is NULL.
  • If indicator returns 0 and valueLength returns 0, the LOB is an Empty LOB.

Diagnosis#

SQLSTATE Description Note
08S01 Communication link fault (Data transmission failure) Communication link failed before function processing is complete between Altibase CLI driver and DB.
HY000 General error
SQLEmptyLob
SQLBindCol
SQLBindParameter
SQLFetch
SQLExecute
SQLGetLob
SQLPutLob

Example#

if (SQLGetLobLength2(stmt, lobLoc, SQL_C_BLOB_LOCATOR, &valueLength, &indicator) != SQL_SUCCESS)
{
    execute_err(dbc, stmt, "SQLGetLobLength : ");
    SQLFreeStmt(stmt, SQL_DROP); 
    return SQL_ERROR;
}