![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Piping output of "top" to a text file | safraser | UNIX for Dummies Questions & Answers | 13 | 05-21-2009 05:13 PM |
| piping output of tail running in background | anuramdas | Shell Programming and Scripting | 4 | 07-27-2007 03:20 PM |
| piping output to echo | A1977 | Shell Programming and Scripting | 3 | 11-01-2006 08:58 AM |
| piping the output of find command to grep | 435 Gavea | UNIX for Dummies Questions & Answers | 1 | 10-05-2006 05:48 PM |
| Piping output to while read | Ultimodiablo | Shell Programming and Scripting | 3 | 11-26-2005 10:38 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
piping oracle output to a file?
Hi All...
Does anyone know how to pipe the output of a "select" statement from a call to Oracle to a file? ANy ideas woule be greatly appreciated! Code is as below... echo "producing CSV file 2..." sqlplus -s $username/$password@$database<<EOF set serveroutput on size 1000000 set verify off set feedback off set pagesize 0 VARIABLE vi_err NUMBER SELECT empno||','||ename||','||job||','||mgr||hiredate||','||sal||','||comm||','||deptno FROM emp; EXIT:vi_err EOF |
|
||||
|
spool
Why dont you spool the output to a file
Code:
set serveroutput on size 1000000 set verify off set feedback off set pagesize 0 spool filename VARIABLE vi_err NUMBER SELECT empno||','||ename||','||job||','||mgr||hiredate||','||sal||','||comm||','||deptno FROM emp; spool off EXIT:vi_err EOF |
|
||||
|
Thanks!
Cheers lads! v useful tips.
I also found another way... as below. { echo "set pagesize 0" echo "SELECT empno||','||ename||','||job||','||mgr||hiredate||','||sal||','||comm||','||deptno "\ "FROM emp;" } | sqlplus -s $username/$password@$database >> $root_dir/$csv_file1 Kind Regards Satnam |
|
||||
|
hi satnam.. is there a way not to mention the user name and pasword in the script. i have a requirement like this. i have to run a sql query using shell scripts. once the query is run, the results have to be stored in a data file. if any values are returned by the query, it should display an error msg to the user or else it has to exit. pls help me with this as i am totally new to shell scripting and i just started to learn..
|
|
||||
|
Quote:
hi, I am new to unix I have executed the following script :- X=`sqlplus service/service@psmf.world <<eof set serveroutput on; set feedback off; set linesize 1000; select count(*) from table ; EXIT; eof` echo $X>testing1.txt .... and got the following output vi testing1.txt SQL*Plus: Release 9.2.0.5.0 - Production on Mon Mar 17 07:57:45 2008 Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved. Connected to: Oracle9i Enterprise Edition Release 9.2.0.5.0 - 64bit Production With the Partitioning option JServer Release 9.2.0.5.0 - Production SQL> COUNT(*) ---------- 270 SQL> Disconnected from Oracle9i Enterprise Edition Release 9.2.0.5.0 - 64bit Production With the Partitioning option JServer Release 9.2.0.5.0 - Production I only want output 270 in the file. How can i get this output? Please give your inputs |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|