Defining/Binding Blob Values

Ruslan Zasukhin sunshine at public.kherson.ua
Fri Aug 15 14:15:38 CDT 2008


On 8/14/08 3:15 PM, "Thomas.DellAnno at swisstopo.ch"
<Thomas.DellAnno at swisstopo.ch> wrote:

Hi Thomas,

Sorry for delay.

Important point:
    Value_blob  in VSDK in fact is analog of Value_ulong, i.e. 4 bytes.

This is because in the table column of BLOB field is just 4 bytes that
reference a start of BLOB segments in the .blb file.

So to store binary data itself you need use FixedBinary or, better,
VarBinary values.

And now I will check your C++ code

------- 
> 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 --------------------------

-- 
Best regards,

Ruslan Zasukhin
VP Engineering and New Technology
Paradigma Software, Inc

Valentina - Joining Worlds of Information
http://www.paradigmasoft.com

[I feel the need: the need for speed]




More information about the Valentina mailing list