The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
suggest book haripatn UNIX for Advanced & Expert Users 6 05-02-2008 02:14 PM
Can you suggest a more efficient way for this? mikie Shell Programming and Scripting 1 11-20-2006 06:49 AM
Look into this and suggest if any changes needed me_haroon AIX 1 07-03-2006 02:39 AM
How to get the knowledge in UNIX? Suggest me . Please. nani_ynm UNIX for Dummies Questions & Answers 2 12-06-2005 07:24 PM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-24-2006
Registered User
 

Join Date: Aug 2006
Posts: 18
Two SQL connections..suggest changes.

Guys,
My requirement is to spool the resultset of an SQL query to a text file.And one of the select columns of the SQL query is obtained dyamically from the result set of 2 other SQL queries.

And shell scripts looks as below:

OUTPUT=$(sqlplus -s xxxx/yyyy@xyz101 << EOF | grep -v "^$"
set head off
select a.col_name
......................;

select a.col_name
......................;
exit
EOF)

ls_curr_fact=$(echo $OUTPUT | awk '{ print $1 }')
ls_last_fact=$(echo $OUTPUT | awk '{ print $2 }')

ls_fact_amount="sum(${ls_curr_fact}-${ls_last_fact})"

sqlplus -s xxxx/yyyy@xyz101 << EOF | tee -a ${LOG_FILE}

SET SHOWMODE off
SET FEEDBACK OFF
SET VERIFY off
SET RECSEP off
SET TRIMSPOOL on
SET LINESIZE 20000
SET HEADING OFF
SET PAGESIZE 0
SET PAGES 0

WHENEVER SQLERROR EXIT SQL.SQLCODE;

spool ${TEMP1}
SELECT 'B'||','||FD.GEO_ID||','||FD.PROD_ID||','||','||','||','||','||$ls_fact_amount.............

You can see the select column "ls_fact_amount" is obtained from the resultset of two other queries above.
The cumbersome with the above block is that I've two SQL connections to the same database instance.
Could someone suggest changes to my block to simply the SQL connections to just one and get my job done.

Thanks,
Bhagat
Reply With Quote
Google UNIX.COM
Forum Sponsor
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 08:53 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0