![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| 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 |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
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 |
|
#3
|
|||
|
|||
|
sqlplus -s <LOGIN>/<password>@<DBCONN> <<-END > <DESTINATIONDIR>/<FLNAME>
|
|
#4
|
|||
|
|||
|
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 ?
|
|
#5
|
|||
|
|||
|
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 |
|||
| Google The UNIX and Linux Forums |