Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Shel Script

Re: Shel Script

From: Robert W. Swisshelm <swisshelm_at_lilly.com>
Date: 1997/07/18
Message-ID: <33CF91AE.4C0C@lilly.com>#1/1

Leo Put wrote:
>
> Kevin Kelleher wrote:
> >
> > On Tue, 15 Jul 1997 22:04:45 -0400, terryg8 <trg_at_ibm.net> wrote:
> >
> > >RISHI ANAND wrote:
> > >>
> > >> Hello All,
> > >>
> > >> Just had a question, as to how could we write a shell script in UNIX, if
> > >> I wanted to execute SQL commands by simply running them within the shell
> > >> script?
>
> Another solution is :
>
> sqlplus <connect string> <<EOF
> spool $1
> select .... from ...
> where ...
> spool off
> EOF
>
> sqlplus will read all statements between <<EOF and EOF
>
> Leo
>
> Leo Put
> Vlaamse UitgeversMaatschappij Belgium
> lp2014_at_vum.be

Now, suppose you want pass your sql to you script.

Here is a c-shell script called dosql

#!/bin/csh -f
echo processing: "$argv"
sqlplus / <<EOF
$argv
exit
EOF Now suppose you want have it process 'select * from cat;'

dosql 'select * from cat;'

You need to put the single quotes around it so that unix would evaluate the *. You also need the semicolon at the end.

-- 
Bob Swisshelm
Eli Lilly and Company
swisshelm_at_lilly.com
Received on Fri Jul 18 1997 - 00:00:00 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US