Re: how to return a record from pl/sql function

From: Tim X <timx_at_spamto.devnul.com>
Date: 12 Feb 2003 16:14:55 +1100
Message-ID: <87el6eqdv4.fsf_at_tiger.rapttech.com.au>


>>>>> "web" == web guy <web-guy01_at_attbi.com> writes:

 web> Yes that is what I want to do, but I can't determine what to put  web> as the return value for the function in the package body.

 web> If in my package my_pkg I define a record:

 web> type my_rec is record (
 web> field1 char, field2 number, filed3 varchar2);

 web> and the function:

 web> function f_my_function (userfield IN VARCHAR2)  web> return my_rec;

 web> This compiles (in JDeveloper).

 web> When I build the package body:

 web> package body my_pkg as

 web>   function f_my_function (userfield IN VARCHAR2) return theData
 web>   my_pkg.my_rec as
 web>     cursor .....

 web> The compiler does not like the return theData my_pkg.my_rec

 web> So I do I return the record to the Oracle Form that called the  web> function?

Make your function definition

function f_my_function(userfield IN VARCHAR2)

        return my_rec
as

   cursor ....

Drop the "theData" - I'm not sure where you get theData from or what it is meant to represent, but the return statement should just be the type of the return value.

Note that pl/sql is VERY picky about the definitions in the package declaration being EXACTLY the same as the one in the package body (only without the ; at the end).

Tim

-- 
Tim Cross
The e-mail address on this message is FALSE (obviously!). My real e-mail is
to a company in Australia called rapttech and my login is tcross - if you 
really need to send mail, you should be able to work it out!
Received on Wed Feb 12 2003 - 06:14:55 CET

Original text of this message