Execute oracle query determined at runtime from a unix script

Login or Register to Reply

Thread Tools Search this Thread
# 1  
Old 02-01-2008
Execute oracle query determined at runtime from a unix script


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;
# 2  
Old 02-01-2008

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

good luk

# 3  
Old 02-01-2008

sqlplus -s <LOGIN>/<password>@<DBCONN> <<-END > <DESTINATIONDIR>/<FLNAME>
# 4  
Old 02-01-2008
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  
Old 02-01-2008
if user need wants to run the query then everything shud be configurable

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

XYZ.DstDir=/path od destination dir

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

Login or Register to Reply

Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Shell script to execute sql query. as7951 Shell Programming and Scripting 4 07-03-2018 06:49 AM
Execute Oracle gather stats via shell script neil.k Shell Programming and Scripting 1 02-26-2015 04:00 AM
Want to use function and execute the below query in script. neel2462 Shell Programming and Scripting 2 02-08-2014 11:32 AM
ksh Array name determined at runtime bs103950 Shell Programming and Scripting 9 04-17-2013 12:17 PM
How to i execute .rdf file oracle report automatically in cron tab unix soumyamishra UNIX for Advanced & Expert Users 0 03-06-2012 06:57 AM
Shell Script to execute Oracle query taking input from a file to form query DevendraG Shell Programming and Scripting 2 11-10-2011 05:56 AM
PROBLEM WITH ORACLE QUERY IN UNIX SCRIPT apple2685 Shell Programming and Scripting 2 06-24-2011 07:07 AM
Execute a shell script from Oracle procedure palanisvr Shell Programming and Scripting 1 05-25-2011 05:26 AM
Shell script to query Oracle table ken002 Shell Programming and Scripting 2 11-18-2010 01:50 AM
Query Oracle tables and return values to shell script that calls the query balaeswari Shell Programming and Scripting 6 02-04-2010 08:35 AM
Execute SQL query in unix script vijays3 Shell Programming and Scripting 8 11-17-2009 01:03 AM
Oracle Query results to be stored in variables using unix Nareshp Shell Programming and Scripting 5 11-16-2009 11:10 AM
TO execute .sql 2005 query file in shell script n2ekhil Shell Programming and Scripting 0 04-01-2009 05:14 AM
How to execute multiple(batch) oracle script in unix mechine ravi gongati Shell Programming and Scripting 2 03-21-2008 07:37 AM
$HOME Not Getting Set for Oracle Scheduler Script at Runtime shew01 Shell Programming and Scripting 4 12-14-2007 07:31 AM