Environment variables


The following is a quick and dirty routine to establish the ability to read a Unix environment variable from within Oracle. All it does is use a simple shell to load the environment variables into a table.

As part of the database startup procedure, run the following

echo "delete from sys.envs;" > env.sql
env | sed "s/^/insert into sys.envs values ('/g;s/=/','/g;s/$/')\;/g" >> env.sql
echo "commit;" >> env.sql

Then when you start the database, you issue:

SVRMGRL> startup 
SVRMGRL> @envs.sql

Obviously this routine could be enhanced for handling special characters (such as handling quotes,equals (=) and semi-colons) within the environment variable values, but typically, these special characters are not often encountered. Similarly, the values will be for that of the Oracle account, but who else's would you want from within the database ?

The workaround for using this routine in NT is to use the SET command and/or download some freeware unix tools