Defining/Binding Blob Values
Thomas.DellAnno at swisstopo.ch
Thomas.DellAnno at swisstopo.ch
Thu Aug 14 07:15:27 CDT 2008
Hello all
I'm using the C++-API and I'm unable to create Blob values and insert/update
them via parameter binding (:1, :2, etc.). I have found solutions that are
working with "DateTime" values (see source code below) and primitive data
types (int, double, etc.) but found none for Blobs. I'm shure I'm missing
something but I didn't find the right answer in the available valentina
documentation.
Here the code fragment: the problem is calling the function "put_Data" of an
"I_ValueBinaryPtr" pointer returns always an null pointer. Is the use of
I_ValueBinary correct in the context of blob handling?
Many thanks in advance and kind regards -- Tom
-- begin c++ - code --------------------------
void test (void)
{
// ... valentina init ... .
ArrayOfValues_Ptr pBinds = new ArrayOfValues();
// Working DateTime param binding
struct tm dt = { 0, 0, 12, 25, 11, 99 };
I_Value_Ptr vdt = database->CreateValue (kTypeDateTime, fNone);
I_ValueDateTime_Ptr pvdt = fbl_dynamic_cast<I_ValueDateTime>(vdt);
pvdt->put_DateTime (dt.tm_year + 1900, dt.tm_mon, dt.tm_mday,
dt.tm_hour,
dt.tm_min,
dt.tm_sec, 0);
pBinds->AddItem (vdt);
// Not working Blob value binding
String blobData = "this is the blob data";
I_Value_Ptr vBlob = database->CreateValue (kTypeBLOB, fNone);
I_ValueBinary_Ptr pvbBlob = fbl_dynamic_cast<I_ValueBinary>(vBlob);
// --> Makes pBlob a null pointer
pvbBlob->put_Data ((uchar*)blobData.getBuffer(), blobData.length());
// --> Throws an exception because pBlob is null.
pBinds->AddItem (vBlob);
// ... query execution ... e.g. "insert into table (fldDayTime,
fldBlob)
// values (:1, :2)" ...
}
-- end c++ - code --------------------------
More information about the Valentina
mailing list