Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

TABLE function to simulate parameterized view

hjz1321Jul 5 2006 — edited Jul 7 2006
Hi all,
Since view can not have parameters, I tried to used stored procedure to return ref cursor then used TABLE function in select statement to simulate a view with parameters, since it's easy to pass parameters to a stored procedure.

The idea is like this

function foo (p1 int, p2 int)
return sys_ref_cursor
c sys_ref_cursor -- sorry, i forgot the buildin ref cursor name, just used
this as pseudo code
is
open c for select * from table_a where col1=:p1 and col2=p2 using p1, p2;
return c;
end;

select * from table(foo(1,2)) does not work, I know that I can iterate throught
the cursor and pipe it out to a SQL type in function foo, then use TABLE
function in SELECT statement. However, it seems so much coding work. Is it the
only way or do you have better idea?

Thanks in advance.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 4 2006
Added on Jul 5 2006
19 comments
609 views