Hi,
i've tried the following:
Query := TOraQuery.Create(Self);
Query.UniDirectional := True;
Query.SQL.Text := 'BEGIN :RESULT := 7/*' + pFunctionCall + '*/; END;';
ResultValue := Query.ParamByName('RESULT').Value;
Now i excpected to get the value "7" in the variable ResultValue.
But the reality, the variable is "unassigned".
Why?
Greetings and thanks
Jens
Function Call with TOraQuery
something like this:
Base:
CREATE OR REPLACE PACKAGE PACKAGE1 is
type DLCUR is ref cursor;
function MY_FUNC(code VARCHAR2) return DLCUR;
end;
CREATE OR REPLACE PACKAGE BODY PACKAGE1 IS
function MY_FUNC(code VARCHAR2) return DLCUR
is
RS DLCUR;
BEGIN
open RS for 'select 123 from DUAL';
return RS;
END MY_FUNC;
END PACKAGE1;
open RS for 'select 123 from DUAL'; !!! Query could be a saved string
Client C++:
QR01->SQL->Text="begin :Cur:=PACKAGE1.MY_FUNC(:PAR1); end;";
QR01->ParamByName("CUR")->DataType=ftCursor;
QR01->ParamByName("PAR1")->AsString="GIVE_ME_CURSOR1";
try {QR01->Open();} catch(...){...}
Base:
CREATE OR REPLACE PACKAGE PACKAGE1 is
type DLCUR is ref cursor;
function MY_FUNC(code VARCHAR2) return DLCUR;
end;
CREATE OR REPLACE PACKAGE BODY PACKAGE1 IS
function MY_FUNC(code VARCHAR2) return DLCUR
is
RS DLCUR;
BEGIN
open RS for 'select 123 from DUAL';
return RS;
END MY_FUNC;
END PACKAGE1;
open RS for 'select 123 from DUAL'; !!! Query could be a saved string
Client C++:
QR01->SQL->Text="begin :Cur:=PACKAGE1.MY_FUNC(:PAR1); end;";
QR01->ParamByName("CUR")->DataType=ftCursor;
QR01->ParamByName("PAR1")->AsString="GIVE_ME_CURSOR1";
try {QR01->Open();} catch(...){...}
You should set data type for query parameters.
Code: Select all
Query.ParamByName('Result').DataType := ftInteger;
Query.Execute;
ResultValue := Query.ParamByName('Result').Value;