Function Call with TOraQuery

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
jfudickar
Posts: 202
Joined: Fri 10 Mar 2006 13:03
Location: Oberursel / Germany

Function Call with TOraQuery

Post by jfudickar » Sat 29 Jul 2006 20:10

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

ozzy
Posts: 3
Joined: Fri 28 Jul 2006 14:17

Post by ozzy » Sun 30 Jul 2006 17:41

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(...){...}

jfudickar
Posts: 202
Joined: Fri 10 Mar 2006 13:03
Location: Oberursel / Germany

Post by jfudickar » Sun 30 Jul 2006 19:08

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

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Mon 31 Jul 2006 12:54

You should set data type for query parameters.

Code: Select all

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

jfudickar
Posts: 202
Joined: Fri 10 Mar 2006 13:03
Location: Oberursel / Germany

Post by jfudickar » Mon 31 Jul 2006 21:48

Thanks.

Thats it.

Greetings
Jens

Post Reply