Thursday, 1 January 2015

How to execute a SQL in Shell Script

#!/bin/bash
echo "STARTED..."
echo "Connecting to SQLPLUS"
sqlplus -L -s alf_ar/alf_ar@intdev <<EOF
prompt Connected to alf_ar@intdev
set serveroutput on size 100000
set head off
set feedback off
prompt executing the sql statement: $1
$1
exit;
EOF
echo "END..."

Save the above content as "runsql.sh"

then execute the following command
nohup sh runsql.sh "select 1 from dual;" > out.txt &

No comments:

Post a Comment