How about using a for loop? Something along the lines of:
Code:
SCRIPTOUTPUT=$TMPPATH/$test.txt
cat /dev/null>$SCRIPTOUTPUT
for i in tablename1 tablename2 tablename3
do
sqlplus -s / << EOF
-- Blank Line --
-- Blank Line --
whenever sqlerror exit sql.sqlcode;
whenever oserror exit failure;
spool $SCRIPTOUTPUT;
set heading off
set echo off
select col1 '|' col2 '|' from $i;
exit;
EOF
done
Something along those lines is what we use at work (not there atm so can't check complete syntax/script for ya).