Skip to Main Content

SQL & PL/SQL

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!

How to pipeline a function with a dynamic number of columns?

122922May 8 2006 — edited Feb 26 2013
Hi everyone,

I'm trying to figure out how to write a piplined function that generates a dynamic SQL statement from its inputs, executes the query, and returns the results of the query in the pipeline. The number and names of the columns in the dynamic query is unknown number until the function is invoked.

I suspect that DBMS_SQL is involved, but can't quite figure out how to construct a row using it that I can use PIPE ROW on. I also can't figure out what data type the function should return (ANYDATASET?)

pseudo-PLSQL follows:

create function myfunction ( param1 varchar2)
return anydataset pipelined
as
query_string := <... do stuff with param1 ...>

< -- >
open a cursor for query_string
determine the number of columns
read a row
PIPE ROW it
<--->


Can what I'm trying to do be done?

Thanks,

Keith
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 26 2013
Added on May 8 2006
27 comments
46,845 views