Page 1 of 1
C++Builder and array column
Posted: Thu 22 Jul 2010 11:26
by banita
I try IBDAC with c++builder 2010.
In delphi TIBCArray works fine but I cant insert into array column under c++builder.
I cant create TIBCArray beacause there is not constructor definiton.
also:
pArray->Connection = pQuery->Connection->Handle;
dont work.
[BCC32 Error] Unit3.cpp(144): E2034 Cannot convert 'void *' to 'TGDSConnection *'
can you create simple example how insert into array column under c++builder?
sory for my poor english
Posted: Fri 23 Jul 2010 13:45
by Dimon
The example of a code for work with array column:
Code: Select all
TIBCArray* Arr = new TIBCArray(IBCSQL->Connection->Handle, IBCSQL->Transaction->Handle, IBCQuery1->FieldByName("INT_ARR1"));
try {
Arr->Cached = True; //Controls applied changes behaviour.
Arr->GetArrayInfo(); //Here we read array dimension and type info
Arr->CreateTemporaryArray();
int Low1, High1;
Low1 = Arr->ArrayLowBound[0];
High1 = Arr->ArrayHighBound[0];
for(int i = Low1; i SetItemAsInteger(&i, 0, 100 + i);
}
IBCSQL->ParamByName("ID")->AsInteger = IBCQuery1->FieldByName("ID")->AsInteger;
IBCSQL->ParamByName("ARR1")->AsArray = Arr;
}
__finally {
Arr->Free();
}
Arr = IBCSQL->ParamByName("ARR2")->AsArray;
Arr->DbHandle = IBCSQL->Connection->Handle;
Arr->TrHandle = IBCSQL->Transaction->Handle;
Arr->TableName = "IBDAC_ARRAYS";
Arr->ColumnName = "CHAR_ARR2";
Arr->GetArrayInfo();
Arr->CreateTemporaryArray();
IBCSQL->ParamByName("ARR2")->AsString =
"(('AA';'BB';'CC'),('DD';'EE';'FF'),('GG';'HH';'II'),('JJ';'KK';'LL'))";
IBCSQL->Execute();
Posted: Fri 23 Jul 2010 21:57
by banita
ok all works fine without Arr->Free(); which cause pointer invalid operation.
I think ibdac delete this pointer.
Posted: Mon 26 Jul 2010 08:57
by Dimon
IBDAC doesn't delete the TIBCArray object that you have created.
If you use the code above without changes is the error arised?
Posted: Mon 26 Jul 2010 10:32
by banita
when I use TIBCArray like this:
Arr = IBCSQL->ParamByName("ARR2")->AsArray;
I must delete them?
Posted: Mon 26 Jul 2010 11:58
by Dimon
No, in this case you mustn't.