I have a loop in Bash, it was working like a charm until today. The loop looks like:
while read line1 ; do
while read line2 ; do
stringArray=($line2)
string=$line1.${stringArray[1]}
sqlplus /nolog <<EOF
connect sysuser/syspassword@db_instance
alter system flush shared_pool;
quit
EOF
sqlplus -s /nolog > /dev/null 2>&1 <<EOF
connect user/password@db_instance
variable rc refcursor;
SPOOL ${line1}_${stringArray[0]}.DATA
exec :rc := $string;
print rc;
spool off
exit
EOF
done < file2.txt
done < file1.txt
To clarify one thing, the contents of the variable $string
are Oracle packages with functions and parameters:
SOMEPACKAGE.SOMEFUNCTION(some,'parameters',here,'sometimes',NULL,'or',numbers)
Now - Until the package was doing what it should do in just one parametrized run - everything was perfectly fine. But now I have encountered a package that does its job in 5 steps, steps determined by the last parameter. It looks like this:
SOMEPACKAGE.SOMEFUNCTION(some,'parameters',here,'sometimes',NULL,'or',1)
SOMEPACKAGE.SOMEFUNCTION(some,'parameters',here,'sometimes',NULL,'or',2)
SOMEPACKAGE.SOMEFUNCTION(some,'parameters',here,'sometimes',NULL,'or',3)
SOMEPACKAGE.SOMEFUNCTION(some,'parameters',here,'sometimes',NULL,'or',4)
SOMEPACKAGE.SOMEFUNCTION(some,'parameters',here,'sometimes',NULL,'or',5)
The first one, with the 1 on end, is producing a TEMPORARY_TABLE
on which the other jobs (2 to 5) are working. The Job number 5 is supposed to give the results of the whole chain too.
Until I had packages doing their Job in 1 step, running this loop was just perfect. But the TEMPORARY_TABLE
is dissappearing after disconnecting, and I cannot just add a special section in my bash script just for this one package, cause there could be much more packages, with different number of steps. This has to be done automatically, without too much effort from the users that will consume this script.
So is there a way of keeping the session alive? Or is there any other way to do this?