accessing run-time parameters from PL/SQL block in a .sql file
Date: 27 Aug 2003 07:00:24 -0700
Message-ID: <57859ba9.0308270600.262e26fd_at_posting.google.com>
Hi folks,
see if u guys can help with any ideas....
I want to write a .sql file to update a table. I know the table name(mytable) , column(mycol1) to be updated , only WHERE clause condition are supplied from sqlplus.
To update 'n' rows i would call from the command-line : sqlplus usr/pw_at_con @my.sql <n> <str-1> <str-2> .....<str-n>
Inside my.sql , i make a pl/sql loop of n times, but do i access the parameters index-wise ?
my.sql
...............
declare
counter number(3,0);
i number(3,0);
strname varchar(30);
.....
begin
counter :=&1; /* Access the first parameter telling strings passed
*/
for i in 1..counter loop strname := &(i+1) /* Access the i+1 th string */ update mytable set mycol1=1 where mycol2='strname'; .................. end loop;
end;
...
This is off course not working. What could be exact syntax ? or do I need to use other stuff like Dynamic sql ?
Thanks in anticipation.
Arijit
Received on Wed Aug 27 2003 - 16:00:24 CEST