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 -> Re: Variable table name in update command

Re: Variable table name in update command

From: Urs Metzger <urs_at_ursmetzger.de>
Date: Wed, 13 Sep 2006 18:52:47 +0200
Message-ID: <ee9cls$67o$1@online.de>


fitzjarrell_at_cox.net schrieb:
> drake wrote:

>> I have a stored procedure that uses a cursor: ...
>> I then wish to update a record in a table based on the data in the >> cursor:
...

>> How can I use a variable for a tablename in an update command?

>
> The same way we've told everyone else how to do it: use dynamic SQL,
> either using dbms_sql or through native dynamic sql (execute
> immediate):
>
> ...
> sqlTxt := 'update '||c.remform||' set status = 3 where action_id =
> '||c.action_id;
> execute immediate sqlTxt;
> ...
>
>
>
> David Fitzjarrell
>

David,

you're teaching how to NOT use bind variables!

Please do:
sqlTxt :=

   'update '||remform||' set status = :st where action_id = :id';

execute immediate sqlTxt using 3, ; Received on Wed Sep 13 2006 - 11:52:47 CDT

Original text of this message

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