Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Can you pass table/view name to a procedure?
Robert Augustyn <augustyn_at_unn.unisys.com> escreveu no artigo
<66rutj$g25$1_at_mail.pl.unisys.com>...
> Hi,
> I would like to pass table name to the stored procedure and use it in one
of
> the sqls inside the procedure but had not much lack doing it, is it
> possible?
> Any solutions will be greatly appreciated.
> Robert
Hi Robert,
Here is a piece of code that can help you:
declare
c integer; t varchar2(40); begin t := 'tablea'; c := dbms_sql.open_cursor; dbms_sql.parse(c,'update '||t||' set column = 10',1); dbms_sql.execute(c); dbms_sql.close_cursor(c);
As you may imagine, the code above will execute dinamically the statement
'update tablea set column = 10'.
See the package spec SYS.DBMS_SQL for more details, and good luck!
-- Luis Cabral cabral_at_merconet.com.brReceived on Sun Dec 14 1997 - 00:00:00 CST