Product Documentation

FairCom Direct SQL for C and C++

Previous Topic

Next Topic

ctsqlSetBlob

Set the blob field.

NOTE: Unlike other ctsqlSet<type>Parameter calls, ctsqlSetBlob must be called immediately after the corresponding ctsqlExecute() to provide LONG, BLOB, or CLOB data for insert/update.

Declaration

CTSQLRET ctsqlSetBlob(pCTSQLCMD hCmd, INTEGER colnumber, void* buffer, INTEGER size, INTEGER offset)

Description

ctsqlSetBlob() sets the value of a blob field (types TPE_DT_LVC or TPE_DT_LVB), given its cursor and column.

  • hCmd the SQL command handle.
  • colnumber the number of the column.
  • buffer the buffer with data to be placed into blob.
  • size the size in bytes of the data in buffer.
  • offset the offset in field where the data is to be placed.

Example

if ((eRet = ctsqlExecuteDirect(hCmd, CT_STRING_LITERAL("create table tab265 (f0 integer, f1 clob)"))) != CTSQLRET_OK)

{

Output("FAIL ctsqlExecuteDirect (%d)\n", eRet);

goto Exit;

}

if ((eRet = ctsqlPrepare(hCmd, CT_STRING_LITERAL("insert into tab265 values (?,?)"))) != CTSQLRET_OK)

{

Output("FAIL ctsqlPrepare (%d)\n", eRet);

goto Exit;

}

if ((eRet = ctsqlSetParameter(hCmd, 0, CTSQL_INTEGER, sizeof(CTSQL_INTEGER), CTSQL_FALSE, &intval)) != CTSQLRET_OK)

{

Output("FAIL ctsqlSetParameter (%d)\n", eRet);

goto Exit;

}

if ((eRet = ctsqlExecute(hCmd, &hCursor)) != CTSQLRET_OK)

{

Output("FAIL ctsqlExecute (%d)\n", eRet);

goto Exit;

}

if ((eRet = ctsqlSetBlob(hCmd, 1, buffer, BLOB_SIZE, 0)) != CTSQLRET_OK)

{

Output("FAIL ctsqlSetBlob (%d)\n", eRet);

goto Exit;

}

ctsqlFreeCursor(hCursor);

Return

ctsqlSetBlob() returns CTSQLRET_OK on success.

Symbolic Constant

Explanation

SQL_ERR_BADPARAM

Bad parameter specification for the statement.

SQL_ERR_INTYPES

Inconsistent types.

TOCIndex