function Execsql
{
STATEMENT="$*"
echo $STATEMENT
sqlplus -s "username/pwd@sid" > /dev/null << END
spool result.out
$STATEMENT;
quit
END
}
Execsql "Select sysdate from dual"
The function Execsql will accept an argument which will be executed by connecting to the DB.
The result will be spooled in result.out file.
The label END should be properly alligned.
No comments:
Post a Comment