Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Accessing UNIX Environment Variables in PL/SQL
Donald J. Merical wrote in message <362614BE.3089_at_ornl.gov>...
>
>How can you access UNIX environment variables and store them into a
>PL/SQL variable?
Assuming that you're running or activating the PL/SQL procedure from a Unix
shell script, it should be fairly straight forward as you can use Unix
variables like this:
--
# !/bin/sh
# sample script (untested)
NAME=$1
SURNAME=$2
echo "
EXECUTE mypackage.adddata('$NAME','$SURNAME');
EXIT;
" > /tmp/~temp$$.sql
sqlplus scott/tiger @/tmp/~temp$$.sql
rm /tmp/~temp$$.sql
--
This is a very simple example I know, but it raises all kinds of
posibilities. For example, you can a table containing Unix variables.
Something like this:
columns: unixpid, unixparam, unixvalue
And then populate this table in the Unix script with the current UNIX process id and env data (fairly simple using grep, awk etc.)
The stored proc can then obtain the current Unix PID from the v$session table for that session and access any of the Unix variables.
When the Unix script terminates, it can delete it's entries from the table.
regards,
Billy
Received on Fri Oct 16 1998 - 06:48:59 CDT