Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Select from a REF CURSOR

Re: Select from a REF CURSOR

From: VC <boston103_at_hotmail.com>
Date: Fri, 07 Nov 2003 22:58:54 GMT
Message-ID: <NsVqb.139367$HS4.1099111@attbi_s01>


Hello Paul,

Here's an example:

create or replace type myType as object (   a int,
  b varchar2(10)
)
/

create or replace type myTable as table of myType; /

create or replace function f1 return myTable as

       l_data myTable := myTable();
begin
 for i in 1 .. 5 loop
   l_data.extend;
   l_data(i) := myType(i, 'Row #'||i );
end loop;
return l_data;
end;
/

select * from TABLE ( cast( f1() as myTable ) );

Rgds.

"Paul Moore" <pf_moore_at_yahoo.co.uk> wrote in message news:u15gm0e0.fsf_at_yahoo.co.uk...
> This may be a dumb question, but I've never got my head round the
> strange TABLE(CAST(...)) syntax. I have a function which returns a REF
> CURSOR. What I'd like to do is to use this function in a SELECT
> statement. Something like:
>
> CREATE FUNCTION f(args) RETURNS SYS_REFCURSOR ...
>
> SELECT * FROM f(1,2,3);
>
> Is this possible, and if so what syntax should I be using?
>
> Thanks,
> Paul.
> --
> This signature intentionally left blank
Received on Fri Nov 07 2003 - 16:58:54 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US