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



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
Running shell scripts from web browser corleone Shell Programming and Scripting 7 07-31-2006 11:11 PM
unix shell scripts for running on solaris srini_ibmadmin UNIX for Advanced & Expert Users 3 06-07-2006 03:28 AM
running vendor shell scripts Javagate UNIX for Dummies Questions & Answers 1 04-13-2004 02:07 PM
Running shell scripts on a remote server pepintheshort UNIX for Dummies Questions & Answers 2 07-22-2003 04:20 PM
Cron running shell scripts. cfoxwell UNIX for Dummies Questions & Answers 3 09-26-2001 11:35 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-28-2006
manthasirisha manthasirisha is offline
Registered User
  
 

Join Date: Jan 2006
Posts: 59
Question Running SQL Scripts from Shell script - Need insight!

I've a script that fetches various values from the database as below:


#! /bin/ksh


$conn="user/pwd@service_name"
`sqlplus -s << $conn EOF1
@xyz.sql
@pqr.sql
@abc.sql
EOF1`

The output of the script should generate txt files containing the results from queries which are further manipulated for display / reporting.
However, when the scripts executes, Oracle throws an exception
SP-0734 : not found .. as against running a direct query within the HERE docs (<< EOF1 EOF1). The same exception doesn't arise when the entire block is assigned to a return variable.

Can someone focus on why this shows up?

TIA
Sirisha
  #2 (permalink)  
Old 06-28-2006
tmarikle tmarikle is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2005
Posts: 683
Try this syntax:
Code:

conn="user/pwd@service_name"
sqlplus -s $conn <<EOF1
@xyz.sql
@pqr.sql
@abc.sql
EOF1
  #3 (permalink)  
Old 06-29-2006
manthasirisha manthasirisha is offline
Registered User
  
 

Join Date: Jan 2006
Posts: 59
Oops.. sorry for that mistake. That's a typo here.. and what i did was what you suggested.. thanx for the correction!

Rather i even tried
`sqlplus -s "user/pwd@service_name" <<EOF1
@xyz.sql
@pqr.sql
@abc.sql
EOF1`

with the same error.. can you pls think of why the error pops up if the whole thing is not assigned to return variable?
Any other suggestions are welcome.

Thnx again!
  #4 (permalink)  
Old 06-29-2006
tmarikle tmarikle is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2005
Posts: 683
Why are you using the back ticks (`)?
  #5 (permalink)  
Old 06-30-2006
manthasirisha manthasirisha is offline
Registered User
  
 

Join Date: Jan 2006
Posts: 59
To consider the sequence of sql statements as single block of execution.. anything wrong with them.
  #6 (permalink)  
Old 06-30-2006
tmarikle tmarikle is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2005
Posts: 683
That is what you are doing with here document enclosed by <<EOF1 and EOF1. The back ticks return the output of the sqlplus command and then, in your case, attempts to execute it.

If you want to capture the output of sqlplus in a variable or an array, then use the back ticks.
Code:
set -A RESULTS_ARRAY `sqlplus -s "user/pwd@service_name" <<EOF1
@xyz.sql
@pqr.sql
@abc.sql
EOF1`

for i in ${RESULTS_ARRAY[@]}
do
    echo $i
done
  #7 (permalink)  
Old 07-03-2006
manthasirisha manthasirisha is offline
Registered User
  
 

Join Date: Jan 2006
Posts: 59
That's pretty clear now! Thank you so much
Sponsored Links
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:28 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
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