how towrite sql in shell scripting

hi
iam new of scipiting.give me the some Material of regarding sql in scripting.
and i have no backup's in 3 severs.how to write script in dirctory.
please give me some usefull information

cheers
Naveen.g

Here is sm example code that you can use accordingly.

  diffdays=`sqlplus -s <username>/<password> <<END
  set pagesize 0
  set feedback off
  set heading off
  set echo off
  set verify off
  select to_date($sysdate, 'yyyymmdd') - to_date($currfile, 'yyyymmdd')   from dual;

diffdays will be having the output of the query in this case

Just make sure you note the heredoc in the example ... and that you make sure to close it:

  diffdays=`sqlplus -s <username>/<password> <<END
  set pagesize 0
  set feedback off
  set heading off
  set echo off
  set verify off
  select to_date($sysdate, 'yyyymmdd') - to_date($currfile, 'yyyymmdd')   from dual;
END `