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
Need Unix script for executing oracle query ravi gongati Shell Programming and Scripting 14 03-24-2008 02:53 AM
How to execute multiple(batch) oracle script in unix mechine ravi gongati Shell Programming and Scripting 2 03-21-2008 04:37 AM
$HOME Not Getting Set for Oracle Scheduler Script at Runtime shew01 Shell Programming and Scripting 4 12-14-2007 05:31 AM
Perl script variable passed to Oracle query rahulrathod Shell Programming and Scripting 1 05-30-2007 05:57 AM
Can Unix (Solaris) execute a dos .bat script? BCarlson UNIX for Dummies Questions & Answers 4 08-26-2006 05:52 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 02-01-2008
Registered User
 

Join Date: Nov 2007
Posts: 55
Execute oracle query determined at runtime from a unix script

Hi

I am trying to run a SQL statement from a unix script determined at runtime.
It is throwing me an error. Please advise some solution to this.

echo "Enter username for the database"
read username

echo "Enter password for the database"
read password

echo "Enter SQL stmt"
read sqlstatement

sqlplus ${username}/${password} <<EOF

spool output.lst;

execute immediate '$sqlstatement';

spool off;
EOF
Reply With Quote
Forum Sponsor
  #2  
Old 02-01-2008
Registered User
 

Join Date: Apr 2007
Location: Kolkata
Posts: 81
Thumbs up

try this

sqlplus -s <LOGIN>/<password>@$DBCONN <<-END > <DESTINATIONDIR>/<FLNAME>
set serveroutput on;
set head off;
set feed off;
set timing off;
set pages 0;
set line 200
<QUERY>
EXIT;
END

good luk

Regards,
Pankaj
Reply With Quote
  #3  
Old 02-01-2008
Registered User
 

Join Date: Apr 2007
Location: Kolkata
Posts: 81
Thumbs up

sqlplus -s <LOGIN>/<password>@<DBCONN> <<-END > <DESTINATIONDIR>/<FLNAME>
Reply With Quote
  #4  
Old 02-01-2008
Registered User
 

Join Date: Nov 2007
Posts: 55
Pankaj, if the query is known to me before running the script, then there is no issue but what if the user is inputting the SQL query to be run at the Run time of the Unix Script ?
Reply With Quote
  #5  
Old 02-01-2008
Registered User
 

Join Date: Apr 2007
Location: Kolkata
Posts: 81
if user need wants to run the query then everything shud be configurable
QUERY,PASSWRD,USENAME,DBCONN etc

i'm giving a sample of configuration file from which u'll have to extract the values and 'll have to proceed

XYZ
XYZ.db=ORACLE
XYZ.Configuration
XYZ.Dbconn=abcXYZ.Login=scott
XYZ.Pass=wljhu
XYZ.Query=SELECT RECORDSEQNUMBER||'|'||CALLIDNUMBER||'|'||RELATEDCALLIDNUMBER||'|'||DATEFORSTARTOFCHARGE||'|'||TIMEFO RSTARTOFCHARGE||'|'||ERRORTYPE||'|'||DATA||'|'||REGION||'|'||SWITCHID||'|'||FILENAME||'|'||DATEOFSUS PENSE||'|'||TIMEOFSUSPENSE||'|'||REPROSTATUS||'|'||ORIGEN_ERROR FROM E1_SUSPENSE;
XYZ.DstDir=/path od destination dir
XYZ.FileName=MM1_E1_SUS.txt

from the configuration file u have to fetch value like this way

QUERY=`grep -w <DBCODE>.Query <Full Path where the configuration file has been placed>/<Name of the configuration file>| cut -f2 -d"="`

good luk

Regards,
Pankaj
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 06:59 AM.


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

Content Relevant URLs by vBSEO 3.2.0