Two SQL connections..suggest changes.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Two SQL connections..suggest changes.
# 1  
Old 10-25-2006
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
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Suggest books

Hi, I'm a beginner and am learning c programming. I want to learn UNIX/LINUX in parallel. But I don't know difference between UNIX and LINUX and where they are applied in real life. As a beginner, some people asked me to start with UNIX. Please let me know some very good books for UNIX. Also a... (6 Replies)
Discussion started by: nerdbee
6 Replies

2. Shell Programming and Scripting

Any body suggest me.........!!!!

i am jaswanth, i am very new to unix/linux, upto now i worked in windows only., but i took coatching for unix.., and my sir teached all my classes in red hat linux and told me that all are same...!!! I know shall programming in red hat linux.., but now i installed opensloaris but the... (5 Replies)
Discussion started by: strgraphics
5 Replies

3. What is on Your Mind?

suggest me books/courses

I am new to unix world. I just know some basic commands only and some basics knowledge about unix. Anyone please suggest me from where should I start. Suggest me some book that could help me from the beginning. Presently I am working in php in a company and I want to move in unix. Please suggest me... (1 Reply)
Discussion started by: UNITRIX
1 Replies

4. Shell Programming and Scripting

please suggest me a site

hi i need to get the values from an xml file like the <TAG> values and write to a file please suggest me the commands and some good reading material sites so that i can implement (1 Reply)
Discussion started by: perlamohan
1 Replies

5. Shell Programming and Scripting

Can yum be used. If not please suggest.

Hi! I need to install a application from one server to several other servers. My script would copy the install-script to other machines and run it.Since it has to be non-interactive , just wondering if yum can be used for the same. Please let me know , if you guys are aware of other... (1 Reply)
Discussion started by: nua7
1 Replies

6. Shell Programming and Scripting

Please suggest some changes in my code

Hi All, I have made the following code which is taking 10-15 mins to execute completely. Here the file am using is very big( around 1050993843). Can any one make some changes in my code which reduces the time it takes to execute as am very much new to Unix(learner). One more thing, i have... (10 Replies)
Discussion started by: madhavsunduru
10 Replies

7. UNIX for Advanced & Expert Users

suggest book

Hi I am new to Unix/Linux I know commands and shell scripts which are useful for my project. But i need to know the basics and commands and shell scripts in detail and easy guide. Please refer a book. Thanks Haripatn (6 Replies)
Discussion started by: haripatn
6 Replies

8. Shell Programming and Scripting

Can you suggest a more efficient way for this?

Hi I have the following at the end of a service shutdown script used in part of an active-passive failover setup: ### # Shutdown all primary Network Interfaces # associated with failover ### # get interface names based on IP's # and shut them down to simulate loss of # heartbeatd ... (1 Reply)
Discussion started by: mikie
1 Replies

9. AIX

Look into this and suggest if any changes needed

Hi, I am new script programming, I have written a script shown velow to read username and passwd from /etc/security/passwd, i am able to read username, but unable to grep lastupdate. please look into the code and suggest if any changes need. #!/bin/ksh USERNAME="" fname=/usr/bin/lastupdate... (1 Reply)
Discussion started by: me_haroon
1 Replies
Login or Register to Ask a Question