Computing.Net > Forums > Unix > sending output to flatfile

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.

sending output to flatfile

Reply to Message Icon

Name: kanaka
Date: April 18, 2008 at 05:55:53 Pacific
OS: unix
CPU/Ram: n/a
Product: n/a
Comment:

Hi,
I am writing one unix script to get row count of few tables into one sequential file
my script is like this
$ORACLE_HOME/bin/sqlplus -s <<EOF >output.txt
userid/password@databasename
set verify off
set heading off
set feedback off
select count(*) count from tablel;
select count(*) count from table2;
select count(*) count from table3;
exit;
EOF

I want the output inoutput.txt file like this

table1 30(record count)
table2 40
table3 50

Can you please help me in gettinh this result

Thanks



Sponsored Link
Ads by Google

Response Number 1
Name: lankrypt0
Date: April 21, 2008 at 06:35:47 Pacific
Reply:

I actually have a whole process that involves SQLPlus and a whole bunch of queries. I recommend sending the queries to their own files so you can just do a line count; something like this:
#!/usr/bin/ksh
sqlplus -s <<EOF > outfile.txt
username/password@database
set verify off
set heading off
set feedback off
spool table1.csv
select count(*) count from tablel;
spool table2.csv
select count(*) count from table2;
spool table3.csv
select count(*) count from table3;
exit;
EOF

wc -l table1.csv table2.csv table3.csv | awk {print $2"\t: "$1}' > outfile.txt
rm table1.csv table2.csv table3.csv


0

Response Number 2
Name: kanaka
Date: April 22, 2008 at 12:26:35 Pacific
Reply:

thanks lankrypt0 for you reply.I will take your Suggestion and will work on this


0

Sponsored Link
Ads by Google
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: sending output to flatfile

sending output to printer www.computing.net/answers/unix/sending-output-to-printer/4053.html

sending output to printer www.computing.net/answers/unix/sending-output-to-printer/4066.html

how to catch the exit status www.computing.net/answers/unix/how-to-catch-the-exit-status-/4098.html