The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #3 (permalink)  
Old 02-06-2007
nhatch nhatch is offline
Registered User
  
 

Join Date: Aug 2002
Location: London, England
Posts: 84
I'm not a great sql person so I normally make a file of the data from the sql statements and then use awk (as sugegsted before) to format how I want it.

I normally put it in a script, a bit like this.

sqlplus -s user/password > a_temp_file <<!
set lin 500
set pages 0
select '~', statement....
....
..;
!

I use the ~ so I can search on it later.

Then with in the same script you can use awk on the a_temp_file to change the format to what you desire. Awk should remove the extra empty spaces.

awk '/~/ {print $1, $2, $3, $4}' a_temp_file > report_file.


You can change the , to <tab> "\t" or any thing else. You can also easily put coloumn names and things like that.

Hope it helps