TOraArray: array of objects and array of numbers

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
m.ghilardi
Posts: 41
Joined: Thu 13 Mar 2014 11:14

TOraArray: array of objects and array of numbers

Post by m.ghilardi » Tue 24 Feb 2015 10:11

I have some trouble working with arrays
ODAC 9.4.13 (C++ Builder)
1)
In order to copy an array of objects this code fails (invalid datatype)

Code: Select all

arr_target->ItemAsObject[i] = arr_source->ItemAsObject[i];
while this works

Code: Select all

arr_target->ItemAsObject[i]->Assign(arr_source->ItemAsObject[i]);
2)
TOraArray lacks of BCD/FMTBCD/Currency itemtype support. I have an array of NUMBER(18,4), I see that ODAC detects the Items as FLOAT.

3)
TOraArray->ItemAsVariant method would be nice..

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: TOraArray: array of objects and array of numbers

Post by AlexP » Tue 24 Feb 2015 13:50

1) The problem is not reproduced. Please send the script for creating database objects and the Delphi code demonstrating the problem.
2) Currently, the object fields type is not changed, not depending on the DataSet options. We will add this functionality in one of the next versions.
3) We will consider the possibility to add this property to the TOraArray class

m.ghilardi
Posts: 41
Joined: Thu 13 Mar 2014 11:14

Re: TOraArray: array of objects and array of numbers

Post by m.ghilardi » Tue 24 Feb 2015 14:39

Hi Alex,
I try to extract some bits of code from a very big project. Let me know if this is enough.
SQL

Code: Select all

create or replace type obj_t as object
(
  a_id          number(18),
  a_string      varchar2(30)
);

create or replace type obj_array_t as varray(10) of obj_t;

create or replace type obj_complex_t as object
(
  a_id          number(18),
  a_params      obj_array_t
);

create table obj_complex_table of obj_complex_t;

--insert some data in obj_complex_table....

create table obj_complex_table2 of obj_complex_t;
In Rad Studio we try to copy the contents of obj_complex_table in obj_complex_table2...

Code: Select all

//QrySource is a TOraQuery "select * from obj_complex_table"
//QryTarget is a TOraQuery "select * from obj_complex_table2"

QrySource->Open();
QryTarget->Open();
TField* idfsource = QrySource->FieldByName(L"a_id");
TField* idftarget = QryTarget->FieldByName(L"a_id");

for(QrySource->First();!QrySource->Eof;QrySource->Next())
{
	QryTarget->Append();

        idftarget->Value = idfsource->Value; 

	TOraArray* arr_source = QrySource->GetArray(L"a_params");
	TOraArray* arr_target = QryTarget->GetArray(L"a_params");

	arr_target->Clear();
	for (int i = 0; i < arr_source->Size; i++)
	{
		arr_target->InsertItem(i);
		if (!arr_source->ItemIsNull[i])
		{
			arr_target->ItemAsObject[i] = arr_source->ItemAsObject[i];  
		}
	}
	QryTarget->Post();
}
We got an error as soon as the program starts copying a_params field. As I mentioned earlier, the following code resolves the problem.

Code: Select all

arr_target->ItemAsObject[i]->Assign(arr_source->ItemAsObject[i]);

m.ghilardi
Posts: 41
Joined: Thu 13 Mar 2014 11:14

Re: TOraArray: array of objects and array of numbers

Post by m.ghilardi » Tue 24 Feb 2015 14:48

I forgot, there is another feature I wish you implement in future versions:
4)
TOraArray->ItemClear(i)

I haven't found a way (besides clearing the entire array) to work around this

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: TOraArray: array of objects and array of numbers

Post by AlexP » Wed 25 Feb 2015 11:10

Your problem is not reproduced on your code execution. Please specify the exact versions of С++ Builder, Oracle server and client.

m.ghilardi
Posts: 41
Joined: Thu 13 Mar 2014 11:14

Re: TOraArray: array of objects and array of numbers

Post by m.ghilardi » Fri 27 Feb 2015 07:48

C++ Builder XE4 (Help Release 1)

Oracle Database 11g Release 11.2.0.3.0 - 64bit Production

Oracle Client 12.1.0.1.0

I'll try to reproduce the problem in a standalone (tiny) project..

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: TOraArray: array of objects and array of numbers

Post by AlexP » Mon 02 Mar 2015 13:00

Please execute your code on the latest ODAC version 9.4.14 and let us know the results.

Post Reply