How to pass variable in PL/SQL block inside the UNIX shell script. Here is the ex-
#!/usr/bin/ksh
declare -a arr=("01", "03", "05", "07", "09", "11")
for i in "${arr[@]}"
do
$ORACLE_HOME/bin/sqlplus -s <<EOF
scott/tiger
set serveroutput on
declare
id = &1
var .........;
begin
for i in (select .... from ..... where id = &id);
loop
select * from ..........;
<pkg>.<sp>(var); -- calling to execute job then process will do
insert into ....... values(&id, ........);
end loop;
end;
In the &id at the time of run this anonymous PL/SQL block statement this value will be vary like 1, 3, 5, 7, 9, 10, 11 like this. It means for every ID this PL/SQL block will run automatically using this Shell script.
For ex, if i run separate PL/SQL block in the SQL developer then for id = 01
set serveroutput on
declare
var .........;
begin
for i in (select .... from ..... where id = 01);
loop
select * from ..........;
<pkg>.<sp>(var); -- calling to execute job then process will do
insert into ....... values(01, ........);
end loop;
end;
Then same for rest of the ID this shell script should be run automatically.
id="01"set before the first line$ORACLE_HOME/... .... <<EOFand then later you can havewhere id = "$id"and later stillvalues ($id,....)? Just do that and it should work. (I don't see the required closingEOFin your first sample code). Good luck.