C++Builder and array column

Discussion of open issues, suggestions and bugs regarding IBDAC (InterBase Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
banita
Posts: 29
Joined: Fri 19 Jun 2009 14:31

C++Builder and array column

Post by banita » Thu 22 Jul 2010 11:26

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

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Fri 23 Jul 2010 13:45

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();

banita
Posts: 29
Joined: Fri 19 Jun 2009 14:31

Post by banita » Fri 23 Jul 2010 21:57

ok all works fine without Arr->Free(); which cause pointer invalid operation.
I think ibdac delete this pointer.

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Mon 26 Jul 2010 08:57

IBDAC doesn't delete the TIBCArray object that you have created.
If you use the code above without changes is the error arised?

banita
Posts: 29
Joined: Fri 19 Jun 2009 14:31

Post by banita » Mon 26 Jul 2010 10:32

when I use TIBCArray like this:

Arr = IBCSQL->ParamByName("ARR2")->AsArray;

I must delete them?

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Mon 26 Jul 2010 11:58

No, in this case you mustn't.

Post Reply