Get CGI env variables in a database procedure using new APEX Listener

I already posted this question in the Apex Listener forum and still no replies after one week. The original post is here:
Get CGI environment from APEX Listener within database procedure
So please forgive me for posting in this forum as well, but there is a lot more activity here.
I'd like to know how I can get the CGI environment from the APEX Listener. For example, if I want to write a procedure that inserts into a table the originating IP Address of the client making the web request, how do I get it?
I am familiar with the Oracle Http Server and mod_plsql, and I know how to call OWA_UTIL.GET_CGI_ENV to get this sort of information. How do I do it using the APEX Listener?
In particular, how do I do this when calling a custom procedure (not in an Apex workspace)? When I try it now, I get an error from owa_util. The cgi env seems to be empty or not initiated (owa.num_cgi_vars is null or zero).
Specific set-up:
I have a web server running the latest JDK, Glassfish, and 1.1.4 Apex Listener. It connects to another server running the latest 11.2 database. Apex is installed and running, but I am not really developing a traditional Apex application in a workspace. I mainly use it like you would use mod_plsql. In other words, I have custom pl/sql packages that are called directly via URL. The requests are forwarded by the listener to the database, and the DB executes the procedure and returns output using htp.p to send text back to the browser. And it works just fine for this purpose. But if I want to call GET_CGI_ENV to get information like the IP Address, web browser making the request, etc. I can't seem to get it with the OWA packages.
Can anyone shed some light on this? If Apex Listener is not designed to do this, is there some kind of workaround I can use to forward this sort of information to the database for each request?

I have not tried owa_util.print_cgi_env from SQL Workshop yet, as I have not created an APEX workspace. I have had no need for a workspace because of the way I am using APEX as a method for calling custom packages and stored procedures. In other words, I am using APEX strictly for the mod_plsql functionality. I just use it to forward requests to the database to execute pl/sql code, but I don't develop anything in APEX. My application is a web service with no screens and no direct user interface, which is why I did not need to create APEX forms. The front end is a mobile app that makes calls to the web service.
But I have tried calling owa_util.print_cgi_env in one of my stored procedures and it returns no data, even when calling it from the web front-end.
So I am beginning to believe that if the OWA toolkit works with APEX, then it must only be enabled when invoked within a workspace. Stand-alone procedures can be called via APEX, but apparently doing so does not initiate the CGI env variables. This set-up used to work under the OHS with mod_plsql. The embedded pl/sql gateway also works this way.
Is there a procedure call that APEX is making to set the environment before each SQL Workshop request?
My security model currently blocks access to all packages and procedures except for my custom packages. I am using the APEX Listener configuration to allow only the packages listed by name in a white list. But I thought I allowed all access when I first tried calling the OWA packages. I'll have to try that again.

Similar Messages

  • CAN I PASS FORM VARIABLES TO THE DATABASE PROCEDURE IN PERSONALIZATION

    When I try to use form variable in the database procedure call from personalization I get the attached error.
    Under forms personalization
    From Actions tab --> builtin --> Execute Procedure when I call a database procedure and pass one of the form variable as parameter I get "ora-01008 couldn't be validate" error
    Can we pass on form variables to the database package using personalization ? If yes, then is this the right way?
    Message was edited by:
    omitchel

    I tried customizing the Quoting Form, it works.
    What you have done is correct, but this is how you call it
    ='begin
    db_proc('''||${item.qothddet_main.quote_name.value}||''');
    end'
    here
    qothddet_main : block name
    quote_name : item name
    Thanks
    Tapash

  • Basic authentication - does owa_util.get.cgi.env return the userid?

    that was entered in the login dialog? How does this relate to the "cookie user" of APEX?
    David

    Hi,
    I came across the same problem today, my current understanding of the problem confirms your suspects, but I am still investigating the matter.
    If you made some progress on this, please share your thoughts.
    Flavio
    http://oraclequirks.blogspot.com
    http://www.yocoya.com

  • Unable to get the data from ms sql stored procedures using crystal report 10

    Dear,
    I am using the crystal report 10 and MS SQL 2000. I created stored procedures and after making the connection, i am unbale the data from that procedure. When i run stored procedure on MS SQL server it works fine.
    Please help me.
    Best Regards
    Pankaj
    [email protected]

    Dear,
    I am using the crystal report 10 and MS SQL 2000. I created stored procedures and after making the connection, i am unbale the data from that procedure. When i run stored procedure on MS SQL server it works fine.
    Please help me.
    Best Regards
    Pankaj
    [email protected]

  • How to pass javascript variable to PLSQL stored procedure

    Hi,
    How can I pass a javascript variable to a database procedure. I have a form with a radio button group and would like to save the value of the selected radio button to a database table by passing the value to the stored procedure.
    Thanks

    Hi
    You can use iframe to call the procedure. Here is an example used in dynamic page or pl/sql portlet. The pl/sql procedure is called myprocedure and resists in the schema myschema. This example passes 2 parameters, but I have not yet reased a limit.
    First the call within a javascript function:
    myiframe.location.href="myschema.myprocedure?p_myprameter1=" + vJvascriptparameter1 + "&p_myprameter2=" + vJvascriptparameter2;
    Then the iframe:
    <iframe id="myiframe" height="0" width="0" frameborder="0"></iframe>
    You can let the pl/sql procedure print a value, that can be used i the portlet. You can get the value in a javascript this way:
    myvalue=top.window.frames["myiframe"].document.body.innerHTML;
    Best regards
    Klaus

  • Is there any way to get windows environment variables like %USERNAME% with javascript?

    is there any way to get windows environment variables like %USERNAME% with javascript using Adobe 10 pro?

    There is a fair amount of Acrobat JavaScript and Acrobat knowledge need to sort all of this out.
    The identity object holds a lot of sedative information. First, upon installation of Acrobat, only the login name is available in the identity object and the end user of the application needs to complete the "Name", "email" and "Organization Name" in the application's preferences. These are the only fields that are available to Acrobat JavaScript identity object as corporation, email, loginName, and name.
    Using the instructions in The Acrobat JavaScript Console (Your best friend for developing Acrobat JavaScript) you can run the following script in the JS console to see the items of the identity object:
    for(i in identity) {
    console.println(i +": " + identity[i]);
    and the following will appear in the console:
    loginName: georgeK
    name: George Kaiser
    corporation: Example
    email: [email protected]
    true
    The documentation states you need to use a trusted function to access this data, but you can access it at startup of Acrobat/Reader and add the properties of the identity object to an array:
    // application variable to hold the properties of the identity object
    var MyIdentity = new Array();
    // loop through the properties of the identity object
    for (i in identity) {
    // place each property of the identity object into an element of the same name in the Identity array
    MyIdentity[i] = identity[i];
    console.println(i +": " + MyIdentity[i])
    You access the items with:
    var loginUser = MyIdentity[loginName];  // get the loginName property
    In the user application level JavaScript file. See Acrobat Help / User JavaScript Changes for 10.1.1 (Acrobat | Reader) for the location of the application level folder you need to use.
    I would change the name of the array used in this post so an untrusted user cannot get to your data. Some of this data can be used in hacking into a user's system.

  • Not able to get SSL related CGI Environment Variables?

    We are currently using APEX 3.2.0.x, OHS 10.1.3.x, and 11gR1 on linux. The APEX application we've been developing will be accessed via SSL and x509 certificates such that a client certificate is passed from a user's browser to the OHS, the information will be read from the certificate, and if the user's cert information exists in a user table associated with the application, they will have the role they've been assigned as an existing user within the application. Otherwise, the user will be a guest and have a minimum role accessing the application.
    We are certainly not guru's when it has come to setting up and configuring SSL and certs, but we have gotten to the point where we have all of the required certs created and installed, and the client cert passes it's information successfully to the OHS to get to the "home" page of the application via the Rewrite statement in the httpd.conf/ssl.conf that points to the appropriate https url. We are now at the point where we need the APEX application page to read the cert information, and this is where we are having problems.
    We have created an "On Load - Before Header" process and temporary item on the "home" page to display CGI environment variables to see what we're getting. It's a PLSQL Anonymous block like this:
    DECLARE
    lUserName VARCHAR2(100);
    BEGIN
    SELECT NVL(owa_util.get_cgi_env('REMOTE_USER'),'NOT POPULATED') INTO lUserName FROM DUAL;
    :P1_REMOTE_USERNAME := lUserName;
    END;
    We can grab any of the cgi environment variables that are listed in the OHS mod_plsql User's Guide. We cannot seem to be able to get any of the SSL CGI environment variables though. We are adding the SSL variables to the dads.conf via the PlsqlCGIEnvironmentList parameter (ex: PlsqlCGIEnvironmentList SSL_CLIENT_S_DN_CN) and bouncing the OHS as needed. Unfortunately, we have not been successful in getting any of them to show up in the item on the APEX page.
    As far as we can tell, we have the SSL/OHS/Certs configured, but may be there is another SSL directive or some other configuration item that we've missed that needs to be set in order for SSL CGI environment variables to be available to the owa_util.get_cgi_env function. If anyone can tell us what we may have missed, it would be appreciated.
    thanks
    bob

    Hey John,
    what we have found that we were not sure of is that we need to use Rewrite rules and conditions in the ssl.conf to grab the ssl cgi environment variables and "put" them into the request header to hold them like this:
    RewriteCond %{SSL:SSL_SERVER_S_DN} (.*)
    RewriteRule .* - [E=SSLS_DN:%1]
    RequestHeader add X-SSL-SERVER-S-DN %{SSLS_DN}e
    Then in the dads.conf put the request header reference in there with the plsqlcgienvironmentlist parameter like this:
    PlsqlCGIEnvironmentList HTTP_X_SSL_SERVER_S_DN
    Restart the OHS, and then grab the HTTP_X_SSL_SERVER_S_DN variable(s) via the owa_util.get_cgi_env in the APEX page to pull the value out with an anonymous block in an On Load - Before Header process like this:
    DECLARE
    lUserName VARCHAR2(100);
    BEGIN
    SELECT NVL(owa_util.get_cgi_env('HTTP_X_SSL_SERVER_S_DN'),'NOTHING HERE') INTO lUserName FROM DUAL;
    END;
    It's the Rewrite rules and putting them into the request header that we were not totally sure about as far as how and where you put the environment variables to make them accessible to the dads.conf with the PlsqlCGIEnvironmentList parameter that in turn makes them accessible to APEX. We're still not 100% sure this is the correct method, but it's working. We don't recall reading in any of the APEX docs, APEX forum threads, or other documentation about needing Rewrite rules and conditions to put the cgi environment variables into the request header to make them accessible to APEX. So, that seems to be our missing piece of the puzzle here.
    Anyway, I think we're okay for the moment, and may be this thread will help someone else out in the future. Thanks for your help John, and will give you a helpful plug on the forum for this thread. BTW, I do have your book, so it was nice to see someone as advanced with APEX as yourself reply to the posting.
    Thanks
    Bob

  • Could the Database Trigger get a forms variable value

    Hi All
    We have an ERP which connect all users of the system with a single schema (Database user name), We create a record for each user in the ERP itself to specify the privillages for each user
    I would like to make a database trigger to Audit a table , by storing the user name, action (Insert,delete,update) on an audit table.
    The problem is the user name i want to store is not the schema name, but it's stored in a database table and read in a global variable.
    Can i get the user name (which stored in the global variable) in the database trigger ???
    Thanks
    Mostafa Abolaynain

    If this global variable lives inside Forms (which the title of your post seems to indicate), then no.
    A database trigger can only reference "stuff" that lives inside the database session at the database server, not "stuff" that lives inside the proces at the client device.
    You should ask your ERP vendor: there might very well be something (eg. a variable inside a database package) that you can use.

  • Getting env variables into servlet

    I am making a call to a servlet http://3.70.201.210/servlets/basic?cmd=Attach
    Apparently, the servlet is not getting some of the environment variables it needs to make use of due to which it fails to load and the browser times out.
    In httpd.conf, I use
    PassEnv TARGET_ROOT
    PassEnv PRODUCT
    but they dont seem to get passed
    It was working before. All I did was upgrade Apache from 1.3.28 to 1.3.29. jserv version has been the same in both versions.
    Any pointers.
    Thanks in advance for any help or suggestions.

    Found it .. adding
    wrapper.env=var=value
    in jserv.properties fixed it !

  • Using CIS to get UCM environment variables

    Hi,
    I am working on extending an existing CIS application.
    I would need to read the UCM's environment variable value.
    I see there are CIS APIs for the most common actions needed, but couldn't find anything useful in the docs - is there something similar for the env variables?
    Any help is highly appreciated.
    Thanks,
    Zoran

    Do you want to get the port and server name from the web server or from the database?
    If it's the web server have a look at the package OWA_Util.print_cgi_env to get a list (you can also run this procedure in the SQL Workshop) of all available environment variables in the HTTP session context. Use OWA_Util.get_env to read the value of a particular environment variable.
    Hope that helps
    Patrick

  • Env variable confusion - newbie install

    Hello,
    I have completed the installation sequence for db 10g (10.2.0.1) on RHEL 4.3 (x86_64). I am somewhat confused by this installation procedure wrt env. variables such as ORACLE_HOME, ORACLE_SID, ORACLE_BASE, etc.
    The pre-installation guidelines are clear in saying that .bash_profile (in this case) for user 'oracle' should NOT set these variables prior to installation:
    8. If the ORACLE_SID, ORACLE_HOME, or ORACLE_BASE environment variable is set
    in the file, then remove the corresponding lines from the file. (Preinstallation Tasks 2-41)
    User 'oracle's .bash_profile does not get updated during installation; subsequent login as 'oracle' shows that the env. variables are not set via other means. Is there a post-installation step I'm missing?
    Thank you again,
    Scott

    oraenv uses the ORACLE_SID to set the ORACLE_HOME and PATH - including making sure the ORACLE_HOME/bin is unique in the PATH
    But ... unless there is a database instance involved, ORACLE_SID is meaningless. It really does not have meaning until dbca is used to create a database, or the manual counterpart to dbca is invoked and oratab is updated.
    I have found there is a Catch-22 related to the oratab/oraenv which seems to have caused oraenv to be undervalued.
    However, due to the possibility of several ORACLE_HOMEs and several databases, since Oracle7 I have used the following sequence in my .profile
    export PATH=$PATH:/usr/local/bin # if not already done
    export ORAENV_ASK=NO
    ORACLE_SID=orcl
    . orenv
    export ORAENV_ASK=
    and then I am able to source /usr/local/bin/oraenv on demand to set te SID, HOME and PATH for any database.
    It's so useful, I add entries for each ORACLE_HOME into the oratab, regardless of whether it represents a database or not. For example, I will have entries for GridAgent, OMS, and so on.
    I can not explain why the oraenv is not better discussed in the documentation. It misses a major 'feature'.

  • How to use OUT variables in my stored procedure

    I'm wondering if I can get some help using OUT variables in my stored procedure. Here's my code...
    CREATE OR REPLACE PROCEDURE testProj.testProcedure (
         v_segment_id IN VARCHAR2,
         v_student_id OUT VARCHAR2,
         v_current_code OUT NUMBER,
         v_new_code OUT NUMBER
    ) AS
    BEGIN
         SELECT
              s.student_id,
              s.quad_code_id,
              nc.quad_code_id
         INTO
              v_student_id,
              v_current_quad_code,
              v_new_quad_code
         FROM testProj.students s
         INNER JOIN testProj.new_codes nc ON s.student_id = nc.student_id
         WHERE s.segment_id = v_segment_id ;
    END testProcedure ;
    EXECUTE testProj.testProcedure ('44') ;
    When I execute that stored procedure with the above execute statement, I get this error:
    Error report:
    ORA-06550: line 1, column 7:
    PLS-00306: wrong number or types of arguments in call to 'testProcedure'
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    +06550. 00000 - "line %s, column %s:\n%s"+
    *Cause:    Usually a PL/SQL compilation error.+
    *Action:+                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    Using Refcursor is one way you can do that ->
    satyaki>
    satyaki>select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
    PL/SQL Release 10.2.0.3.0 - Production
    CORE    10.2.0.3.0      Production
    TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
    NLSRTL Version 10.2.0.3.0 - Production
    Elapsed: 00:00:00.21
    satyaki>
    satyaki>
    satyaki>create or replace procedure r_arg(
      2                                      choice in number,
      3                                      b in out sys_refcursor
      4                                   )
      5  is  
      6    str   varchar2(500);
      7  begin   
      8     str := 'select * from emp';   
      9     open b for str;
    10  exception  
    11    when others then     
    12      dbms_output.put_line(sqlerrm);
    13  end;
    14  /
    Procedure created.
    Elapsed: 00:00:01.84
    satyaki>
    satyaki>
    satyaki>declare   
      2    rec_x emp%rowtype;   
      3    w sys_refcursor;
      4  begin  
      5    dbms_output.enable(1000000);  
      6    r_arg(1,w);  
      7    loop    
      8      fetch w into rec_x;     
      9        exit when w%notfound;             
    10        dbms_output.put_line('Employee No: '||rec_x.empno||' - '||                          
    11                             'Name: '||rec_x.ename||' - '||                          
    12                             'Job: '||rec_x.job||' - '||                          
    13                             'Manager: '||rec_x.mgr||' - '||                          
    14                             'Joining Date: '||rec_x.hiredate||' - '||                          
    15                             'Salary: '||rec_x.sal||' - '||                          
    16                             'Commission: '||rec_x.comm||' - '||                          
    17                             'Department No: '||rec_x.deptno);  
    18     end loop;  
    19     close w;    
    20  exception  
    21    when others then    
    22       dbms_output.put_line(sqlerrm);
    23  end;
    24  /
    Employee No: 9999 - Name: SATYAKI - Job: SLS - Manager: 7698 - Joining Date: 02-NOV-08 - Salary: 55000 - Commission: 3455 - Department No: 10
    Employee No: 7777 - Name: SOURAV - Job: SLS - Manager:  - Joining Date: 14-SEP-08 - Salary: 45000 - Commission: 3400 - Department No: 10
    Employee No: 7521 - Name: WARD - Job: SALESMAN - Manager: 7698 - Joining Date: 22-FEB-81 - Salary: 1250 - Commission: 500 - Department No: 30
    Employee No: 7566 - Name: JONES - Job: MANAGER - Manager: 7839 - Joining Date: 02-APR-81 - Salary: 2975 - Commission:  - Department No: 20
    Employee No: 7654 - Name: MARTIN - Job: SALESMAN - Manager: 7698 - Joining Date: 28-SEP-81 - Salary: 1250 - Commission: 1400 - Department No: 30
    Employee No: 7698 - Name: BLAKE - Job: MANAGER - Manager: 7839 - Joining Date: 01-MAY-81 - Salary: 2850 - Commission:  - Department No: 30
    Employee No: 7782 - Name: CLARK - Job: MANAGER - Manager: 7839 - Joining Date: 09-JUN-81 - Salary: 4450 - Commission:  - Department No: 10
    Employee No: 7788 - Name: SCOTT - Job: ANALYST - Manager: 7566 - Joining Date: 19-APR-87 - Salary: 3000 - Commission:  - Department No: 20
    Employee No: 7839 - Name: KING - Job: PRESIDENT - Manager:  - Joining Date: 17-NOV-81 - Salary: 7000 - Commission:  - Department No: 10
    Employee No: 7844 - Name: TURNER - Job: SALESMAN - Manager: 7698 - Joining Date: 08-SEP-81 - Salary: 1500 - Commission: 0 - Department No: 30
    Employee No: 7876 - Name: ADAMS - Job: CLERK - Manager: 7788 - Joining Date: 23-MAY-87 - Salary: 1100 - Commission:  - Department No: 20
    Employee No: 7900 - Name: JAMES - Job: CLERK - Manager: 7698 - Joining Date: 03-DEC-81 - Salary: 950 - Commission:  - Department No: 30
    Employee No: 7902 - Name: FORD - Job: ANALYST - Manager: 7566 - Joining Date: 03-DEC-81 - Salary: 3000 - Commission:  - Department No: 20
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.48
    satyaki>
    satyaki>Regards.
    Satyaki De.

  • How to get system Environment variable?

    How to get system Environment variable without using jni?
    just like "JAVA_HOME" or "PATH"...
    Any reply is help to me!! :-)

    Thx for your reply...
    I get it!!!
    Read environment variables from an application
    Start the JVM with the "-D" switch to pass properties to the application and read them with the System.getProperty() method. SET myvar=Hello world
    SET myothervar=nothing
    java -Dmyvar="%myvar%" -Dmyothervar="%myothervar%" myClass
    then in myClass String myvar = System.getProperty("myvar");
    String myothervar = System.getProperty("myothervar");
    This is useful when using a JAVA program as a CGI.
    (DOS bat file acting as a CGI) java -DREQUEST_METHOD="%REQUEST_METHOD%"
    -DQUERY_STRING="%QUERY_STRING%"
    javaCGI
    If you don't know in advance, the name of the variable to be passed to the JVM, then there is no 100% Java way to retrieve them.
    NOTE: JDK1.5 provides a way to achieve this, see this HowTo.
    One approach (not the easiest one), is to use a JNI call to fetch the variables, see this HowTo.
    A more low-tech way, is to launch the appropriate call to the operating system and capture the output. The following snippet puts all environment variables in a Properties class and display the value the TEMP variable. import java.io.*;
    import java.util.*;
    public class ReadEnv {
    public static Properties getEnvVars() throws Throwable {
    Process p = null;
    Properties envVars = new Properties();
    Runtime r = Runtime.getRuntime();
    String OS = System.getProperty("os.name").toLowerCase();
    // System.out.println(OS);
    if (OS.indexOf("windows 9") > -1) {
    p = r.exec( "command.com /c set" );
    else if ( (OS.indexOf("nt") > -1)
    || (OS.indexOf("windows 2000") > -1 )
    || (OS.indexOf("windows xp") > -1) ) {
    // thanks to JuanFran for the xp fix!
    p = r.exec( "cmd.exe /c set" );
    else {
    // our last hope, we assume Unix (thanks to H. Ware for the fix)
    p = r.exec( "env" );
    BufferedReader br = new BufferedReader
    ( new InputStreamReader( p.getInputStream() ) );
    String line;
    while( (line = br.readLine()) != null ) {
    int idx = line.indexOf( '=' );
    String key = line.substring( 0, idx );
    String value = line.substring( idx+1 );
    envVars.setProperty( key, value );
    // System.out.println( key + " = " + value );
    return envVars;
    public static void main(String args[]) {
    try {
    Properties p = ReadEnv.getEnvVars();
    System.out.println("the current value of TEMP is : " +
    p.getProperty("TEMP"));
    catch (Throwable e) {
    e.printStackTrace();
    Thanks to W.Rijnders for the W2K fix.
    An update from Van Ly :
    I found that, on Windows 2003 server, the property value for "os.name" is actually "windows 2003." So either that has to be added to the bunch of tests or just relax the comparison strings a bit: else if ( (OS.indexOf("nt") > -1)
    || (OS.indexOf("windows 2000") > -1 )
    || (OS.indexOf("windows 2003") > -1 ) // works but is quite specific to 2003
    || (OS.indexOf("windows xp") > -1) ) {
    else if ( (OS.indexOf("nt") > -1)
    || (OS.indexOf("windows 20") > -1 ) // probably is better since no other OS would return "windows" anyway
    || (OS.indexOf("windows xp") > -1) ) {
    I started with "windows 200" but thought "what the hell" and made it "windows 20" to lengthen its longivity. You could push it further and use "windows 2," I suppose. The only thing to watch out for is to not overlap with "windows 9."
    On Windows, pre-JDK 1.2 JVM has trouble reading the Output stream directly from the SET command, it never returns. Here 2 ways to bypass this behaviour.
    First, instead of calling directly the SET command, we use a BAT file, after the SET command we print a known string. Then, in Java, when we read this known string, we exit from loop. [env.bat]
    @set
    @echo **end
    [java]
    if (OS.indexOf("windows") > -1) {
    p = r.exec( "env.bat" );
    while( (line = br.readLine()) != null ) {
    if (line.indexOf("**end")>-1) break;
    int idx = line.indexOf( '=' );
    String key = line.substring( 0, idx );
    String value = line.substring( idx+1 );
    hash.put( key, value );
    System.out.println( key + " = " + value );
    The other solution is to send the result of the SET command to file and then read the file from Java. ...
    if (OS.indexOf("windows 9") > -1) {
    p = r.exec( "command.com /c set > envvar.txt" );
    else if ( (OS.indexOf("nt") > -1)
    || (OS.indexOf("windows 2000") > -1
    || (OS.indexOf("windows xp") > -1) ) {
    // thanks to JuanFran for the xp fix!
    p = r.exec( "cmd.exe /c set > envvar.txt" );
    // then read back the file
    Properties p = new Properties();
    p.load(new FileInputStream("envvar.txt"));
    Thanks to JP Daviau
    // UNIX
    public Properties getEnvironment() throws java.io.IOException {
    Properties env = new Properties();
    env.load(Runtime.getRuntime().exec("env").getInputStream());
    return env;
    Properties env = getEnvironment();
    String myEnvVar = env.get("MYENV_VAR");
    To read only one variable : // NT version , adaptation for other OS is left as an exercise...
    Process p = Runtime.getRuntime().exec("cmd.exe /c echo %MYVAR%");
    BufferedReader br = new BufferedReader
    ( new InputStreamReader( p.getInputStream() ) );
    String myvar = br.readLine();
    System.out.println(myvar);
    Java's System properties contains some useful informations about the environment, for example, the TEMP and PATH environment variables (on Windows). public class ShowSome {
    public static void main(String args[]){
    System.out.println("TEMP : " + System.getProperty("java.io.tmpdir"));
    System.out.println("PATH : " + System.getProperty("java.library.path"));
    System.out.println("CLASSPATH : " + System.getProperty("java.class.path"));
    System.out.println("SYSTEM DIR : " +
    System.getProperty("user.home")); // ex. c:\windows on Win9x system
    System.out.println("CURRENT DIR: " + System.getProperty("user.dir"));
    Here some tips from H. Ware about the PATH on different OS.
    PATH is not quite the same as library path. In unixes, they are completely different---the libraries typically have their own directories. System.out.println("the current value of PATH is: {" +
    p.getProperty("PATH")+"}");
    System.out.println("LIBPATH: {" +
    System.getProperty("java.library.path")+"}");
    gives the current value of PATH is:
    {/home/hware/bin:/usr/local/bin:/usr/xpg4/bin:/opt/SUNWspro/bin:/usr/ccs/bin:
    /usr/ucb:/bin:/usr/bin:/home/hware/linux-bin:/usr/openwin/bin/:/usr/games/:
    /usr/local/games:/usr/ccs/lib/:/usr/new:/usr/sbin/:/sbin/:/usr/hosts/:
    /usr/openwin/lib:/usr/X11/bin:/usr/bin/X11/:/usr/local/bin/X11:
    /usr/bin/pbmplus:/usr/etc/:/usr/dt/bin/:/usr/lib:/usr/lib/lp/postscript:
    /usr/lib/nis:/usr/share/bin:/usr/share/bin/X11:
    /home/hware/work/cdk/main/cdk/../bin:/home/hware/work/cdk/main/cdk/bin:.}
    LIBPATH:
    {/usr/lib/j2re1.3/lib/i386:/usr/lib/j2re1.3/lib/i386/native_threads:
    /usr/lib/j2re1.3/lib/i386/client:/usr/lib/j2sdk1.3/lib/i386:/usr/lib:/lib}
    on my linux workstation. (java added all those execpt /lib and /usr/lib). But these two lines aren't the same on window either:
    This system is windows nt the current value of PATH is:
    {d:\OrbixWeb3.2\bin;D:\jdk1.3\bin;c:\depot\cdk\main\cdk\bin;c:\depot\
    cdk\main\cdk\..\bin;d:\OrbixWeb3.2\bin;D:\Program
    Files\IBM\GSK\lib;H:\pvcs65\VM\win32\bin;c:\cygnus
    \cygwin-b20\H-i586-cygwin32\bin;d:\cfn\bin;D:\orant\bin;C:\WINNT\system32;C:\WINNT;
    C:\Program Files\Dell\OpenManage\Resolution Assistant\Common\bin;
    d:\Program Files\Symantec\pcAnywhere;
    C:\Program Files\Executive Software\DiskeeperServer\;C:\Program Files\Perforce}
    LIBPATH:
    {D:\jdk1.3\bin;.;C:\WINNT\System32;C:\WINNT;d:\OrbixWeb3.2\bin;D:\jdk1.3\bin;
    c:\depot\cdk\main\cdk\bin;c:\depot\cdk\main\cdk\..\bin;
    d:\OrbixWeb3.2\bin;D:\Program Files\IBM\GSK\lib;
    H:\pvcs65\VM\win32\bin;c:\cygnus\cygwin-b20\H-i586-cygwin32\bin;d:\cfn\bin;
    D:\orant\bin;C:\WINNT\system32;
    C:\WINNT;C:\Program Files\Dell\OpenManage\ResolutionAssistant\Common\bin;
    d:\Program Files\Symantec\pcAnywhere;
    C:\Program Files\Executive Software\DiskeeperServer\;C:\Program Files\Perforce}

  • ODI Procedure: Using Variable Logical Schema

    Hi!
    i wrote a PL\SQL procedure inside an odi procedure, using options, variables etc.
    now we need to execute the procedure in different logical schemas.
    We've at least 20 different logical schemas and to semplify the maintenance we'd like to pass the logical schema as an Option or something similar,
    is it possibile to do this with a procedure?
    The version of ODI is 11.1.1.5.0 and the targets are only Oracle DB.

    I've got a question : are all you schema in the same server (database) ?
    If so, you can LIST the schemas with a SQL Statement in the "command as SOURCE" tab.
    example :
    select owner as SCHEMA
    from all_tables
    where ...or a SQL Statement in ODI MASTER_Repository to get the logical schema :
    select lschema_name as SCHEMA
    from snp_lschema t1
    where ...And in the "command as destination" tab, you execute the PL SQL, but you use the result of SCHEMA.
    As a result, if you have 40 schema retrieved by the first SQL Statement, ODI will execut your PL/SQL statement 40 times, changing the SCHEMA value each time.
    And, in the first tab (command as destination), you use a generic Oracle User that have access to all schema of the dabase (or at least, the 40 schema you want).

  • Setting env variables through scheduler

    Hi All,
    I am trying to run a PERL script which makes database connection using DBI module through scheduler. The script works fine if I run it manually but from scheduler it fails because it can't fine libclnt.sh.10.1 lib file. I have LD_LIBRARY_PATH & LIBPATH set in my .profile and i guess when scheduler runs the external job, it creates a new shell but doesn't inherit the .profile settings (same as cron). I tried setting these env variables in PERL script itself but even then it's not working. I tried my theory by running this script from shell but without running .profile and it fail with exact same error.
    I want to know how you guys are handling this situation? How to set or call .profile from scheduler job so that all the env variable get set properly?
    OS: SUSE Linux
    DB: 11gR2
    Thanks
    Daljit Singh

    Thanks for the reply, I am doing the same. I have create a very simple script where I am setting all the env variables and I can see that those variable are getting set but still, it doesn't work. There is something special when we run .profile, that time along with env variables, something else also get set (which i dont know and trying to find out) which makes PERL to search the oracle library in oracle_home. I can see that by turning libraries debugging on. Here is a small snippet when .profile doesn't get execute but the env variables are set:
    25039: find library=libclntsh.so.10.1 [0]; searching
    25039: search cache=/etc/ld.so.cache
    25039: search path=/lib64/tls/x86_64:/lib64/tls:/lib64/x86_64:/lib64:/usr/lib64/tls/x86_64:/usr/lib64/tls:/usr/lib64/x86_64:/usr/lib64 (system search path)
    25039: trying file=/lib64/tls/x86_64/libclntsh.so.10.1
    25039: trying file=/lib64/tls/libclntsh.so.10.1
    25039: trying file=/lib64/x86_64/libclntsh.so.10.1
    25039: trying file=/lib64/libclntsh.so.10.1
    25039: trying file=/usr/lib64/tls/x86_64/libclntsh.so.10.1
    25039: trying file=/usr/lib64/tls/libclntsh.so.10.1
    25039: trying file=/usr/lib64/x86_64/libclntsh.so.10.1
    25039: trying file=/usr/lib64/libclntsh.so.10.1
    25039:
    install_driver(Oracle) failed: Can't load '/usr/lib/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/auto/DBD/Oracle/Oracle.so' for module DBD::Oracle: libclntsh.so.10.1: cannot open shared object file: No such file or directory at /usr/lib/perl5/5.8.8/x86_64-linux-thread-multi/DynaLoader.pm line 230.
    at (eval 3) line 3
    Compilation failed in require at (eval 3) line 3.
    Perhaps a required shared library or dll isn't installed where expected
    at /home/oracle/scripts/test 9
    See it is searching for this lib in some system path and not using any of env variable. I want to know where it's getting this value from. Also if I run .profile then, this path changes and inludes what is mentioned in LD_LIBRARY_PATH and then it works.
    Thanks
    Daljit Singh

Maybe you are looking for