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: UNIX script problem with sqlplus

Re: UNIX script problem with sqlplus

From: Ronald <ronr_at_wxs.nl>
Date: Sat, 22 Aug 1998 16:07:17 +0200
Message-ID: <01HW.B2049D35000517E702438410@news.wxs.nl>

On Thu, 20 Aug 1998 11:13:49 +0200, Nuno Guerreiro wrote (in message <35dbe6f2.865232728_at_news.telecom.pt>):

> 
> On Thu, 20 Aug 1998 08:31:12 +0100, tics28@"spam-off"email.sps.mot.com (Alan 
> Long) wrote: 
> 

>> I have a unix file temp1.sql containing:
>>
>> spool temp1
>>
>> select part_id from product ;
>>
>> spool off
>>
>> I want to run this automatically using crontab, so I have a unix file
>> temp1.run containing:
>>
>> . ~/.profile sqlplus userid/password < temp1.sql mail
>> tics28_at_email.sps.mot.com < temp1.lst
>>
>> This essentially works but temp1.lst contains:
>>
>> SQL> SQL> select part_id 2 from product 4 ;
>>
>> PART_ID ----------------------------------- A/32 SQL> SQL> spool off
>>
>>
>> How can I suppress the SQL prompts and the sqlplus code from the output,
>> so that I only get the data? When I run temp1.sql from within sqlplus,
>> the output file temp1.lst just contains:
>>
>> PART_ID ----------------------------------- A/32
>>
>> As is probably quite obvious, I don't have a lot of UNIX ability!
>>
>> --
> 
> The sqlplus command has support for running a SQL script on startup. Thus 
> you don't need to have the shell redirect input to sqlplus from a file. 
> Simply invoke sqlplus in the following way: 
> 
> sqlplus userid/password @temp1 
> 
> 
> In case you need to pass any parameters to your SQL script, you can also put 
> them on the command-line, e.g.: 
> 
> sqlplus userid/password @temp1 abc 

start sqlplus in silent mode (sqlplus -s) disable feedback etc using
set feed off
set head off
set pages 0
set veri off

Now you only get the results of the query, no headers prompts etc.

Cheers

--
Ronald



mailto:ronr_at_wxs.nl
http://home.wxs.nl/~ronr/RonR.html (last update: june 8th, 1998) http://www.maccentral.com/news/9804/migration.shtml (forward migration home) Received on Sat Aug 22 1998 - 09:07:17 CDT

Original text of this message

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