Defining/Binding Blob Values
Ivan Smahin
ivan_smahin at paradigmasoft.com
Thu Aug 14 07:45:11 CDT 2008
Hello Thomas,
Thursday, August 14, 2008, 3:15:27 PM, you wrote:
> 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 --------------------------
You should use kTypeFixedBinary instead of kTypeBLOB for vBlob value.
I_Value_Ptr vBlob = database->CreateValue (kTypeFixedBinary, fNone);
--
Best regards,
Ivan Smahin
Senior Software Engineer
Paradigma Software, Inc
Valentina - The Ultra-Fast Database
http://www.valentina-db.com
More information about the Valentina
mailing list