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

sql query in unix scritp

Reply to Message Icon

Original Message
Name: rajkumargnv
Date: August 5, 2004 at 10:09:04 Pacific
Subject: sql query in unix scritp
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


Report Offensive Message For Removal


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

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


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: sql query in unix scritp

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




Have you ever used OpenOffice?

Yes, as my main suite.
Yes, occationally.
Yes, but only once.
No, never.


View Results

Poll Finishes In 5 Days.
Discuss in The Lounge