Computing.Net > Forums > Unix > sql query in unix scritp

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

sql query in unix scritp

Reply to Message Icon

Name: rajkumargnv
Date: August 5, 2004 at 10:09:04 Pacific
OS: SCO Unix
CPU/Ram: 512
Comment:

I have a batch file that starts up the oracle, executes a query and spools the result to a text file and exits. The code goes like this...
sqlplus ccn/yak25 @C:\temp\script.sql
notepad.exe C:\temp\output.txt

and script.sql has the code:
spool C:\temp\output.txt
select * from emp;
spool off
exit

I want to do the same job on Unix, do I write a shell script like this
#!/bin/sh

sqlplus 'username/password@instance' '@dir/query.sql>dir/output.txt
exit
OR
nave the same spool stteaments in the query.sql file and delete dir/output.txt from the script?

Please help



Sponsored Link
Ads by Google

Response Number 1
Name: Dlonra
Date: August 5, 2004 at 17:33:15 Pacific
Reply:

sqlplus 'username/password@instance'<<!
@dir/query.sql>dir/output.txt
exit
!


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: sql query in unix scritp

How to write a sql query in a shell www.computing.net/answers/unix/how-to-write-a-sql-query-in-a-shell/8033.html

SQL in shell script www.computing.net/answers/unix/sql-in-shell-script/5703.html

How to generate xls file in unix www.computing.net/answers/unix/how-to-generate-xls-file-in-unix/5629.html