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

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Environment Variables

 



yakirllc
New User

May 28, 2017, 7:02 AM

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

Hi,

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

Code
$ENV{"ORACLE_SID"}="test"; 
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.


BillKSmith
Veteran

May 28, 2017, 8:29 AM

Post #2 of 3 (3463 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,
Bill


FishMonger
Veteran / Moderator

May 28, 2017, 8:44 AM

Post #3 of 3 (3462 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
https://metacpan.org/pod/DBI

2) DBD::Oracle - Oracle database driver for the DBI module
https://metacpan.org/pod/DBD::Oracle

 
 


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

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