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 -> Challenge? dynamic query in store procedure

Challenge? dynamic query in store procedure

From: Alan <non>
Date: Sun, 08 Dec 2002 19:10:15 GMT
Message-ID: <3df39709.134830145@news.telocity.com>


In a store procedure, I try to pass in fileld and table name to construct a dynamic query and return the cursor, here is the code:

create or replace procedure TestIt(fieldname in varchar2, tablename in varchar2, p_cursor in out types.cursorType )

is

begin

      open p_cursor for select fieldname from tablename;

end;

But it encounters compilation error and I believe the reason is that there only be static query in the store procedure.

Maybe I can get my way by using DBMS_SQL package, such as

DBMS_SQL.Parse(); 
DBMS_SQL.Define_Column(); 
DBMS_SQL.EXECUTE(); 
DBMS_SQL.Fetch_Rows(); 

However I do not know how to return the cursor back to the caller.

Thanks,

Alan Received on Sun Dec 08 2002 - 13:10:15 CST

Original text of this message

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