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
select count(*) in sqlplus into variable unix shell struggle UNIX for Dummies Questions & Answers 2 03-26-2008 11:12 PM
passing unix variable to sqlplus without a file name sakthi.abdullah UNIX for Advanced & Expert Users 3 12-12-2006 06:35 AM
Sqlplus antkiu Shell Programming and Scripting 4 09-14-2006 01:36 AM
How to pass unix variable to SQLPLUS chiru UNIX for Advanced & Expert Users 1 06-10-2006 03:11 AM
How to pass variable to SQLPLUS in a ksh script? rwunwla Shell Programming and Scripting 6 05-25-2006 06:41 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 09-25-2006
MadHatter MadHatter is offline
Registered User
  
 

Join Date: Jun 2005
Location: New York City
Posts: 20
Using a variable in sqlplus

Hello,

I'm trying to write a script that will loop a sql statement through an external list. Basically, the script enters a loop and runs the sql statement for each entry in the list file. Currently, the script will stop at a cursor where I can then manually enter the SQL statment. This is what I have so far:

Port_count.ksh
Quote:
PRTFLIST='/home/oracle/PortConversion/tradePort.list'
DATADIR='/home/oracle/PortConversion'


# Source the login information
. $HOME/Dear/jobs/DRU/login_DRU.ksh

cd /home/oracle/chris/PortConversion
$ORACLE_HOME/bin/sqlplus -s $DBO_USER/$DBO_PASS

#get the row count for each portfolio
while read $PRTFLIST; do



select count (*) from dear_trade_snapshot where id_prtf_stars = '{$prtf}'
;
done < $PRTFLIST
tradePort.list
Quote:
1MB
1AK
1AP
Can anyone help?

Thanks,
Chris
  #2 (permalink)  
Old 09-25-2006
aigles's Avatar
aigles aigles is offline Forum Advisor  
Registered User
  
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,429
You can try something like that :

Code:
PRTFLIST='/home/oracle/PortConversion/tradePort.list'
DATADIR='/home/oracle/PortConversion'

# Source the login information
. $HOME/Dear/jobs/DRU/login_DRU.ksh

cd /home/oracle/chris/PortConversion

#get the row count for each portfolio
while read prtf; do
   echo "select count (*) from dear_trade_snapshot where id_prtf_stars = '$prtf'"
done > | \
$ORACLE_HOME/bin/sqlplus -s $DBO_USER/$DBO_PASS  </dev/null

Jean-Pierre.
  #3 (permalink)  
Old 09-25-2006
MadHatter MadHatter is offline
Registered User
  
 

Join Date: Jun 2005
Location: New York City
Posts: 20
Quote:
Originally Posted by aigles
You can try something like that :

Code:
PRTFLIST='/home/oracle/PortConversion/tradePort.list'
DATADIR='/home/oracle/PortConversion'

# Source the login information
. $HOME/Dear/jobs/DRU/login_DRU.ksh

cd /home/oracle/chris/PortConversion

#get the row count for each portfolio
while read prtf; do
   echo "select count (*) from dear_trade_snapshot where id_prtf_stars = '$prtf'"
done > | \
$ORACLE_HOME/bin/sqlplus -s $DBO_USER/$DBO_PASS  </dev/null

Jean-Pierre.
Hi Jean-Pierre,

Thank you for your reply. I have tried what you suggested and still receive the same issue, with a syntax error that | is unexpected.
  #4 (permalink)  
Old 09-25-2006
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,131
how about:

Code:
#!/bin/ksh

PRTFLIST='/home/oracle/PortConversion/tradePort.list'
DATADIR="$(dirname ${PRTFLIST)"

# Source the login information
. $HOME/Dear/jobs/DRU/login_DRU.ksh

cd /home/oracle/chris/PortConversion

#get the row count for each portfolio
while read prtf; do
   echo "select count (*) from dear_trade_snapshot where id_prtf_stars = '$prtf'"
done < "${PRTFLIST}" | \
$ORACLE_HOME/bin/sqlplus -s $DBO_USER/$DBO_PASS  </dev/null

  #5 (permalink)  
Old 09-25-2006
MadHatter MadHatter is offline
Registered User
  
 

Join Date: Jun 2005
Location: New York City
Posts: 20
vgersh99, I gave that a shot, and now i see that it connects and disconnects to sqlplus, however I don't think its running the script as it happens instantaniously (sp?) and nothing is printed between the connect and disconnect. I did remove the -s as well.
  #6 (permalink)  
Old 09-25-2006
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,131
Quote:
Originally Posted by MadHatter
vgersh99, I gave that a shot, and now i see that it connects and disconnects to sqlplus, however I don't think its running the script as it happens instantaniously (sp?) and nothing is printed between the connect and disconnect. I did remove the -s as well.
I am no sqlplus expert, but.... try removing the '< dev/null'
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 04:19 AM.


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