Passing parameter from the command line [message #39642] |
Tue, 30 July 2002 13:49 |
Francois
Messages: 8 Registered: March 2002
|
Junior Member |
|
|
I'm writing a PL/SQL program in a Unix environment which I run via the sqlplus command.
How can I pass parameters from the command line and how do I refer to these parms from within the PL/SQL program ??
Thanks for any help.
|
|
|
Re: Passing parameter from the command line [message #39643 is a reply to message #39642] |
Tue, 30 July 2002 14:47 |
ctg
Messages: 146 Registered: July 2002
|
Senior Member |
|
|
not 100% sure what you are asking, but here it goes:
inside your script:
you can reference the first parameter &1
you can reference the second parameter &2
you can reference the third parameter &3
so you do:
sqlplus user/pwd @script A B C
so A would be referenced by &1
so B would be referenced by &2
so C would be referenced by &3
Hope this is what you were looking for
|
|
|
Re: Passing parameter from the command line [message #39645 is a reply to message #39642] |
Tue, 30 July 2002 22:51 |
Misha
Messages: 25 Registered: October 2001
|
Junior Member |
|
|
Here is my example of the Kshell script that passes parameters to the
oracle:
#! /usr/bin/ksh
# get the current date
today=`date +"%m/%d/%Y %T"`
# run procedure
sqlplus $UNAME/$PASS <<EOF
whenever sqlerror exit 1
set serveroutput on
alter session set nls_date_format = 'mm/dd/yyyy hh24:mi:ss'
/
exec fleet_forecast_wa('${today}');
exit success
EOF
sqlplus_rc=$?
if [[[[ $sqlplus_rc = 1 ]]]] ;then
# do whatever is needed to indicate a failure
echo "Failed."
exit 1
else
echo "Completed Successfully."
fi
--Michael
--msosis@jbas-inc.com
|
|
|