Re: Passing parameters to sql*plus ??
Date: 1996/08/24
Message-ID: <321F6D7E.6236_at_idcomm.com>#1/1
Try these options:
- Use the \n escaped character to echo a new line between parameters. Note: \n produces a line feed; \r produces carriage return
echo "$FIRST_VAR\n$SECOND_VAR" | sqlplus user/pass
2. Create a temp file
tmpfile=`mktemp`
echo $VAR_ONE >$tmpfile
echo $VAR_TWO >$tmpfile
sqlplus user/pass <$tmpfile
rm $tmpfile
3. Let unix do the work for creating the temp file and removing it.
<<EOD has the script contents piped to sqlplus until EOD is read <<-EOD has the initial white space on the left removed before piping
which simply makes the script more legible
sqlplus user/pass <<-EOD
$VAR_ONE $VAR_TWO EOD
4. In your code use &1, &2 and &3 to reference first, second and third
parameters. (The quotes ensure that a variable with spaces is still processed by the shell as a single variable.)
sqlplus user/pass "$VAR1" "$VAR2" "$VAR3"
Good luck!
Ted Goulden wrote:
>
> I've been trying to do this as well and have only been able to do it
> with one parameter. I use:
> echo "parm_value" | sqlplus user/password
>
> moan_at_sn.no (Alexander Moan) wrote:
>
> >Howdy (or something) !
> >How do I pass parameters to sqlplus on startup of a script ?
> >I have been able to do a workaround to this by using an
> >append of define *something* into login.sql from a unix shell-scipt,
> >but i don't like this approach.
>
> You cannot access UNIX variables inside sqlplus as far as I know thats
> why I use the above to pass it in. I wish I knew a way to do more than
> one.
>
> echo $ENV_VALUE | sqlplus user/password
> >Is it possible to access Unix env. variables from inside sql*plus ?
> >Any help appreciated !
> >--
> >----------------------------------------------------------
> >| Alexander Moan --:-) moan_at_sn.no |
> >| Any statements I make are my own, and are not to be |
> >| taken as an statement from my employer. |
> >| |
> >| Norwgian Defence Command Norway |
> >| Home Guard Staff |
> >| |
> >| "Don't blame me, I just work here !" |
> >---------------------------------------------------------
Received on Sat Aug 24 1996 - 00:00:00 CEST