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: Kevin Kelleher <kevink_at_mit.edu>
Date: 1997/07/16
Message-ID: <33ccc734.1582595@news.mit.edu>#1/1

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? (It could be any shell, c, korn,...etc..) I tried using the
>> script with "sqlplus/ but it just gets stuck at the sqlplus prompt and
>> waits for me to input some SQL commands....I think I must be missing
>> something....any idea...?
>>

I used Perl to do this, but the principle has to be the same.

You can't just write your sqlplus commands to stdout; Sqlplus won't see them. You have to pipe the commands in. I don't know how to do this sort of redirection in sh. An easy way out is to build a sqlplus command file (you can do this dynamically) and then when it's ready you just

  sqlplus name/password @that_file_you_built

The way I did it in perl was to open the sqlplus session

  open (SQLPLUS, "| sqlplus name/password");

and then any time I wanted to send a command,

  print SQLPLUS "select name, weight, whatever from kitchen_table";

and then you read the results from STDOUT.

Kevin Kelleher Received on Wed Jul 16 1997 - 00:00:00 CDT

Original text of this message

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