Page 1 of 1
TOraArray: array of objects and array of numbers
Posted: Tue 24 Feb 2015 10:11
by m.ghilardi
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..
Re: TOraArray: array of objects and array of numbers
Posted: Tue 24 Feb 2015 13:50
by AlexP
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
Re: TOraArray: array of objects and array of numbers
Posted: Tue 24 Feb 2015 14:39
by m.ghilardi
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]);
Re: TOraArray: array of objects and array of numbers
Posted: Tue 24 Feb 2015 14:48
by m.ghilardi
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
Re: TOraArray: array of objects and array of numbers
Posted: Wed 25 Feb 2015 11:10
by AlexP
Your problem is not reproduced on your code execution. Please specify the exact versions of ะก++ Builder, Oracle server and client.
Re: TOraArray: array of objects and array of numbers
Posted: Fri 27 Feb 2015 07:48
by m.ghilardi
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..
Re: TOraArray: array of objects and array of numbers
Posted: Mon 02 Mar 2015 13:00
by AlexP
Please execute your code on the latest ODAC version 9.4.14 and let us know the results.