About Function [message #1432] |
Tue, 30 April 2002 02:08 |
Manoj
Messages: 101 Registered: August 2000
|
Senior Member |
|
|
can i return a table type from a function
if yes then pl. send me a sample.
ASAP
MANOJ
|
|
|
Re: About Function [message #1445 is a reply to message #1432] |
Wed, 01 May 2002 04:28 |
John R
Messages: 156 Registered: March 2000
|
Senior Member |
|
|
Yes you can.
The datatype that you return needs to be defined somewhere that is visible to both the function and the calling session.
So, you could put the function in a package and define the type in the package header like this:
CREATE OR REPLACE PACKAGE example AS
TYPE ty_table IS TABLE OF varchar2 INDEXED BY binary_integer;
FUNCTION user_function (p_parameter IN number)
RETURN ty_table;
END example;
or, if you want the function to be a stand alone one (for some hard to understand reason), you could define the type in the header of a different package like this:
CREATE OR REPLACE PACKAGE example AS
TYPE ty_table IS TABLE OF varchar2 INDEXED BY binary_integer;
END example;
CREATE OR REPLACE FUNCTION user_function (p_parameter IN number)
RETURN example.ty_table AS
....
END user_function;
Hope this helps.
|
|
|