Page 1 of 1

Function Call with TOraQuery

Posted: Sat 29 Jul 2006 20:10
by jfudickar
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

Posted: Sun 30 Jul 2006 17:41
by ozzy
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(...){...}

Posted: Sun 30 Jul 2006 19:08
by jfudickar
Yes i know. But this is to much complicated.

My workaround is using a select from dual, but there must be an other way.

Greetings
Jens

Posted: Mon 31 Jul 2006 12:54
by Plash
You should set data type for query parameters.

Code: Select all

  Query.ParamByName('Result').DataType := ftInteger;
  Query.Execute;
  ResultValue := Query.ParamByName('Result').Value;

Posted: Mon 31 Jul 2006 21:48
by jfudickar
Thanks.

Thats it.

Greetings
Jens