Defining/Binding Blob Values
Ruslan Zasukhin
sunshine at public.kherson.ua
Fri Aug 15 14:16:41 CDT 2008
On 8/14/08 3:15 PM, "Thomas.DellAnno at swisstopo.ch"
<Thomas.DellAnno at swisstopo.ch> wrote:
>
> 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?
Also, this is our code from REALbasic plugin:
ArrayOfValues_Ptr BuildArrayOfBinds( REALobjectArray inBinds,
FBL::I_Database* inDatabase )
{
ArrayOfValues_Ptr pBinds = new ArrayOfValues();
ulong count = (ulong) REALGetArrayUBound( inBinds );
for( ulong i = 0; i <= count; ++i )
{
REALobject obj = REALGetArrayObject( inBinds, int(i) );
long vtype;
bool res = REALGetPropValue( obj, "Type", &vtype );
I_Value_Ptr a;
switch( vtype )
{
case 0: // nil
{
a = inDatabase->CreateValue(
kTypeString,
fNullable,
0 );
a->put_IsNull( true );
}break;
case 2: // int
{
a = inDatabase->CreateValue(
kTypeLong,
fNullable );
long iv;
res = REALGetPropValue( obj, "IntegerValue", &iv );
a->put_Long( iv );
}break;
case 3: // Int64 or UInt64
{
a = inDatabase->CreateValue(
kTypeLLong,
fNullable );
long long iv;
res = REALGetPropValue( obj, "Int64Value", &iv );
a->put_LLong( iv );
}break;
case 5: // Double
{
a = inDatabase->CreateValue(
kTypeDouble,
fNullable );
double dv;
res = REALGetPropValue( obj, "DoubleValue", &dv );
a->put_Double( dv );
}break;
case 7: // Date
{
a = inDatabase->CreateValue(
kTypeDateTime,
fNullable );
I_ValueDateTime_Ptr pValueDateTime =
fbl_dynamic_cast<I_ValueDateTime >( a );
ushort inYear = 0;
ushort inMonth = 0;
ushort inDay = 0;
ushort inHour = 0;
ushort inMinute = 0;
ushort inSecond = 0;
REALGetPropValue( obj, "Year", &inYear );
REALGetPropValue( obj, "Month", &inMonth );
REALGetPropValue( obj, "Day", &inDay );
REALGetPropValue( obj, "Hour", &inHour );
REALGetPropValue( obj, "Minute", &inMinute );
REALGetPropValue( obj, "Second", &inSecond );
pValueDateTime->put_Date( inYear, inMonth, inDay );
pValueDateTime->put_Time( inHour, inMinute, inSecond, 0 );
}break;
case 8: // String
{
REALstring sv;
res = REALGetPropValue( obj, "StringValue", &sv );
long length = sv->Length();
a = inDatabase->CreateValue(
kTypeString,
fNullable,
&length );
Str_Unicode suv( sv );
a->put_String( suv.c_str(), suv.end() );
}break;
case 9: // Object
{
REALmemoryBlock sv = (REALmemoryBlock)obj;
int length = REALMemoryBlockGetSize(sv);
char* pData = (char*)REALMemoryBlockGetPtr(sv);
a = inDatabase->CreateValue(
kTypeFixedBinary,
(length == 0) ? fNullable : fNone,
&length );
a->put_String( pData, pData + length );
}break;
case 11: // Boolean
{
a = inDatabase->CreateValue(
kTypeBoolean,
fNullable );
Boolean bv;
res = REALGetPropValue( obj, "BooleanValue", &bv );
a->put_Boolean( bv );
}break;
default:
{
FBL_CHECK(false);
}
}
pBinds->AddItem( a );
}
return pBinds;
}
--
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