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 and shell scripting languages 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 06:14 PM
Can you suggest a more efficient way for this? mikie Shell Programming and Scripting 1 11-20-2006 10:49 AM
Look into this and suggest if any changes needed me_haroon AIX 1 07-03-2006 06:39 AM
How to get the knowledge in UNIX? Suggest me . Please. nani_ynm UNIX for Dummies Questions & Answers 2 12-06-2005 11:24 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-25-2006
bhagat.singh-j bhagat.singh-j is offline
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
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:24 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0