Originally posted by mkalter:
The package wizard does support collection object parameters. They are implemented as TOracleObjects.
The generated package class will have a TOracleObject parameter, which you need to instantiate in your application as a 'KANAELE' type:
Code:
Kanaele := TOracleObject.Create(MySession, 'KANAELE', '');
Kanaele[0] := ...;
Kanaele[1] := ...;
MyPackage.MyFunction(Kanaele, ...);
The package wizard does not support PL/SQL Tables of non-sclalar data types, but this is not the case here.
I have changed the package a bit, but I can't understand whats happening:
create or replace package PRDS$DATA is
TYPE kanaele_real IS TABLE OF INTEGER;
TYPE kanaele_string IS TABLE OF VARCHAR2(254);
declarations
function transfer_oracle_real(i_zeitstempel TIMESTAMP, i_kanaele IN kanaele_real) return NUMBER;
function transfer_oracle_string(i_zeitstempel TIMESTAMP, i_kanaele IN kanaele_string) return NUMBER;
end PRDS$DATA;
The package wizard makes the following:
// PRDS$DATA.TRANSFER_ORACLE_REAL
function TPrdsData.TransferOracleReal(const IZeitstempel: string;
IKanaele: TOracleObject): Double;
begin
ThreadAcquire;
try
GetQuery;
OCPQuery.DeclareVariable('function_result', otFloat);
OCPQuery.DeclareVariable('I_ZEITSTEMPEL', otString);
OCPQuery.SetVariable('I_ZEITSTEMPEL', IZeitstempel);
OCPQuery.DeclareVariable('I_KANAELE', otObject);
OCPQuery.SetComplexVariable('I_KANAELE', IKanaele);
OCPQuery.SQL.Add('begin');
OCPQuery.SQL.Add(' :function_result := "PRDS$DATA"."TRANSFER_ORACLE_REAL"(');
OCPQuery.SQL.Add(' I_ZEITSTEMPEL => :I_ZEITSTEMPEL,');
OCPQuery.SQL.Add(' I_KANAELE => :I_KANAELE);');
OCPQuery.SQL.Add('end;');
OCPQuery.Execute;
Result := ConvertVariant(OCPQuery.GetVariable('function_result'));
finally
ThreadRelease;
end;
end;
Why is the wizard treating the kanaele_real datatype (table of integer) as an oracle object and then uses setcomplexvariable?
OCPQuery.DeclareVariable('I_KANAELE', otObject);
OCPQuery.SetComplexVariable('I_KANAELE', IKanaele);
If I program somthing like this, an error rises, that kanal_table is not an TOracleObject, which is obviously right:
Kanal_Table := TPLSQLTable.Create(100,0);
Kanal_Table.Count := 10;
Kanal_Table[0] := 123;
Test.TransferOracleReal(now, kanal_table);
What can I do?