MIN_BATCH=`sqlplus -s user/pw@sid<<eof
set serveroutput on;
set feedback off;
set linesize 1000;
SELECT to_char(Min(IF_ROW_BATCH_NUM),'999999999999999')MIN FROM SIEBEL.EIM_SRV_REQ WHERE IF_ROW_STAT = 'FOR RECUR IMPORT';
`
min="${MIN_BATCH#"${MIN_BATCH%%[[:digit:]]*}"}" # strip off non-digit prefix from str ...........................................................................
=================================
Now I have to pick multiple values/rows rather than just the minimum batch number. So I need to traverse the table row by row.
sqlplus -s user/pw@sid > /tmp/$$ <<eof
set serveroutput on;
set feedback off;
set linesize 1000;
SELECT * FROM table;
EOF
while read LINE
do
...
done < /tmp/$$
rm -f /tmp/$$
Better to use a temp file than to cram it in backticks because if the output is large enough, backticks will truncate it.
It'd be more easily possible to pipe it into the while loop instead of storing in a temp file if you used a sql script:
sqlplus -s user/pw@sid < script.sql | while read LINE
do
...
done