CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Intermediate:
Environment Variables


New User

May 28, 2017, 7:02 AM

Post #1 of 3 (4989 views)
Environment Variables Can't Post


Is there a way to set new environment varaibles using perl?
Using the $ENV is not good enough.

print `echo \$ORACLE_SID`;

Will return an empty string.
Which means, the ORACLE_SID variable wasn't set in the system.
The reason I need a way to make it work is because I need to be able to run an Oracle query using sqlplus, and I'm not allowed to use the tnsnames.ora(which will allow me to use the username@InstanceName convention).
So my only option is to set the ORACLE_SID variable and then use the sqlplus as follows:
sqlplus -S user/passwd @"queryFileName.sql"

Thanks for the help.


May 28, 2017, 8:29 AM

Post #2 of 3 (4985 views)
Re: [yakirllc] Environment Variables [In reply to] Can't Post

No, you cannot do this. The reason has nothing to do with perl. Environmental variables only pass information to lower level programs. They cannot return information to any other program. I believe that this is true on all operating systems.
Good Luck,

Veteran / Moderator

May 28, 2017, 8:44 AM

Post #3 of 3 (4984 views)
Re: [yakirllc] Environment Variables [In reply to] Can't Post

If you're needing to connect to oracle from within the perl script then use the capabilities that perl provides instead of shelling out to sqlplus.

You need 2 perl modules.
1) DBI - Database independent interface for Perl

2) DBD::Oracle - Oracle database driver for the DBI module


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives