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

Home -> Community -> Usenet -> c.d.o.misc -> Re: Can you pass table/view name to a procedure?

Re: Can you pass table/view name to a procedure?

From: Luis Cabral <cabral_at_merconet.com.br>
Date: 1997/12/14
Message-ID: <01bd0878$76149500$LocalHost@lcdc>#1/1

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);

end;

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.br
Received on Sun Dec 14 1997 - 00:00:00 CST

Original text of this message

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