Farshid Farshid - 4 years ago 265
Bash Question

Connect to sqlplus in a shell script and run SQL scripts

I have a .sql file, which is a bunch of oracle pl/sql commands and I want to create a shell script to run these commands.

Suppose that

user/pass@server
is my credentials. What will be the shell script to do such a task?

Answer Source

For example:

sqlplus -s admin/password << EOF
whenever sqlerror exit sql.sqlcode;
set echo off 
set heading off

@pl_script_1.sql
@pl_script_2.sql

exit;
EOF
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download