SQL select statement in UNIX inside/within IF..THEN statement
This sounds like you're trying to embed SQLPlus in a shell script. From memory the incantation should look something like:
if [ $? -eq ABC ]; thenSQLPLUS /S USER/PASS@Instance <<EOFSET echo off;SET pagesize 0;SET heading off;SPOOL foo.outselect foo from barEOFfi
Everything between the SQLPLUS and EOF is passed to SQLPlus, so we have some statements to control the formatting (you may want different ones) and the actual query. The SPOOL command in the SQLPlus script sends the output to a file. For more detailed docs on using SQLPlus, You can download them from Oracle's web site.