how to execute the sql quires from shell script?

hi all,

I'm new to shell scripting, i want to know how to use the sql statements from the shell script? is there any documents or pdf to learn from the begining? plese provide me some useful links on the same.

Thanks all in advance..,:b:

#! /bin/sh
sqlplus -s user/passwd@DatabaseName << ENDSQL
select * from report;
exit;
ENDSQL
if [[ $? -eq 0 ]]
then
print "SQL succeeded"
else
print "SQL failed"
exit 1
fi

Hope this URL will help you.

ORACLE-BASE - Oracle Shell Scripting

Hi.
Shell script with Informix, 2 options:

#!/bin/ksh
echo "select count(*) from $1" | dbaccess BBDD

dbaccess BBDD <<!
select count(*) from $1
!

If you want to fetch data, then you need to include
m=`sqlplus -s username/password@tnsname <<EOF
set head off
set feed off
set verify off
select count(1) from x_table;
exit;
EOF`

This will provide you the output of count(1) in variable.
-s will take you into silent mode .. you can choose to include or exclude it accordingly ..