SQLAPI++ supports four types for working with this kind of data (see Server specific notes later on this page for details about how SQLAPI++ maps this types on a different SQL platforms):

TypeDescription
LongBinary
SA_dtLongBinary
Generally this type is mapped to an appropriate SQL type that holds long binary data of variable length but does NOT supports "handle" semantics
LongChar
SA_dtLongChar
Generally this type is mapped to an appropriate SQL type that holds long character data of variable length but does NOT supports "handle" semantics
BLob (Binary Large object)
SA_dtBLob
Generally this type is mapped to an appropriate SQL type that holds large binary data of variable length and does supports "handle" semantics
CLob (Character Large object)
SA_dtCLob
Generally this type is mapped to an appropriate SQL type that holds large character data of variable length and does supports "handle" semantics

Working with Long or Lob data includes the following:

Binding Long or Lob Data

Let say we want to update BLob field named FBLOB from table named TEST where some other field named FKEY is equal to 'KEY':

UPDATE TEST SET FBLOB = :fblob WHERE FKEY = 'KEY'

Field should be updated with the content of a file named 'blob.bin'.

First, initialize the command object:

SACommand cmd(
    &con, 
    "UPDATE TEST SET FBLOB = :fblob WHERE FKEY = 'KEY'");

For more information see Execute SQL Statement.

Next step is to actually bind the content of a file into input variable. The following code binds parameter :fblob with value of file content read:

SAString sContent = SomeFunctionThatReadFileContent("blob.bin");
cmd.Param("fblob").setAsBLob() = sContent;

All that we need now is to execute a query:

cmd.Execute();

For using piecewise capabilities of SQLAPI++ for binding Long or Lob types see example.

Reading Long or Lob data

Let's say we want to retrieve BLob field named FBLOB from table named TEST where some other field named FKEY (primary key) is equal to 'KEY':

SELECT FBLOB FROM TEST WHERE FKEY = 'KEY'

Field should be read into a file named 'blob.bin'.

First, create command object:

SACommand cmd(
    &con,
    "SELECT FBLOB FROM TEST WHERE FKEY = 'KEY'");

For more information see Execute SQL Statement.

Then execute the query:

cmd.Execute();

Finally, fetch the row(s) and access BLob data:

while(cmd.FetchNext())
{
    SAString sBLob = cmd.Field("FBLOB").asBLob();
    SomeFunctionToSaveBLobToFile("blob.bin", sBLob);
}

For using piecewise capabilities of SQLAPI++ for reading Long or Lob types see this example.

Need Help?
Send an e-mail to support@sqlapi.com if you want to ask code-level questions, if you’re stuck with a specific error or need advise on the library best practices.