This discussion is archived
1 2 Previous Next 18 Replies Latest reply: Jan 7, 2013 11:32 AM by user11141511 RSS

how to use windows environment variable "%appdata%" in TEXT_IO built-in

user11141511 Newbie
Currently Being Moderated
Hello Sir/Madam,

I'm currently using TEXT_IO built-in package to write data file user's "C" drive in Oracle Forms 6i on Windows XP OS. We are in the process of upgrading the OS to Windows7. This new version does not allow to write to "C" or "D" drive. I was wondering how I can use windows environment variable "%appdata%" in this built-in to write the data file to user's AppData folder?

I would appreciate your help.

Regards,
Vani Sonti
  • 1. Re: how to use windows environment variable "%appdata%" in TEXT_IO built-in
    Andreas Weiden Guru
    Currently Being Moderated
    You should be able to get the value of the environment-setting app_data using the built-in-function TOOLENV.GETVAR.
  • 2. Re: how to use windows environment variable "%appdata%" in TEXT_IO built-in
    vansul Pro
    Currently Being Moderated
    you can access the environment variables data using webutil utility to access getvar(varname); at client hosts machine.
    you can use temp or tmp vaiable too for this purpose..
  • 3. Re: how to use windows environment variable "%appdata%" in TEXT_IO built-in
    Andreas Weiden Guru
    Currently Being Moderated
    There is no WEBUTIL in forms 6i..
  • 4. Re: how to use windows environment variable "%appdata%" in TEXT_IO built-in
    user11141511 Newbie
    Currently Being Moderated
    Hello Andreas,

    From my computer if I use "RUN" command any type "%appdata%" it goes to " C:\Documents and Settings\sontiv\Application Data "
    for convenience sake I have added folder called "GFS" and I use "%appdata%\GFS" to go that specific folder.

    In your suggestion, you mentioned to use TOOLENV.GETVAR to get value of "C:\Documents and Settings\sontiv\Application Data\GFS "
    that means I need define this path in the default.env file in order to use the built-in function..

    Catch is that, how can I determine the path based on the login? for ex: "sontiv" is my login in the "C:\Documents and Settings\sontiv\Application Data\GFS " path
    but, if some one else logs in it should go to that user's "appdata" folder

    Is there a way?

    Regards,
    Vani Sonti
  • 5. Re: how to use windows environment variable "%appdata%" in TEXT_IO built-in
    Christian Erlinger Guru
    Currently Being Moderated
    Quoting the online documentation for tool_env.getvar (the real online version has vanished a loooong time ago; you'd find it via help => online help in your forms builder though)
    TOOL_ENV.Getvar
    Description Provides a way to import an environment variable into a VARCHAR variable.
    Syntax PROCEDURE Tool_Env.Getvar (varname VARCHAR2, varvalue VARCHAR2);
    Parameters varname  The name of the environment variable.  
    varvalue The value of the environment variable.
    Tool_Env.Getvar example
    /*
    ** Retrieve the environment variable USER into a
    ** variable named :userid so you can use it in a
    ** connect string or other call.
    */
    Tool_Env.Getvar('USER', :userid);
    So in (client/server) forms 6i you could simply get the APPDATA folder via
    tool_env.getvar('APPDATA', your_variable);
    in webforms this would give you the appdata folder on the application server; for forms 10g and above there is webutil for that; in lower versions you'd need to implement your own java bean in order to be able to get client environment variables.

    cheers
  • 6. Re: how to use windows environment variable "%appdata%" in TEXT_IO built-in
    user11141511 Newbie
    Currently Being Moderated
    Hello Chirstian,

    Ok.. when I attempted this step it is prompting PLS-00201 error

    I defined two variable in "C:\oradev6i\FORMS60\server\default.env" file
    appdt=C:\Documents and Settings\
    appdat=\Application Data\GFS

    I'm combining them with "user" to send it login user's folder based on who ever is logged in:

    for example, this procedure is prompting error:
    1 create or replace procedure toolEnv_value is
    2 tst varchar2(100);
    3 tst2 varchar2(100);
    4 begin
    5 Tool_Env.Getvar('appdt',tst);
    6 Tool_Env.Getvar('appdat',tst2);
    7 dbms_output.put_line(tst||user||tst2);
    8* end;
    SQL> /

    Warning: Procedure created with compilation errors.

    SQL> show error
    Errors for PROCEDURE TOOLENV_VALUE:

    LINE/COL ERROR
    -------- -------------------------------------------------------------
    5/12 PLS-00201: identifier 'TOOL_ENV.GETVAR' must be declared
    5/12 PL/SQL: Statement ignored
    6/11 PLS-00201: identifier 'TOOL_ENV.GETVAR' must be declared
    6/11 PL/SQL: Statement ignored

    why it is prompting pls-00201 error?


    also, I just now reilaized that I have to use windows login as oppose to application user login, so I'm using some thing like this..

    SELECT SYS_CONTEXT ('USERENV', 'OS_USER') from dual

    capturing that info., into a variable and passing that .. it works ok in Toad or SqlPlus , but forms 6i is

    prompting "sys_context" must be declared error.. why I'm not sure..


    Vani

    Edited by: user11141511 on Jan 7, 2013 10:36 AM

    Edited by: user11141511 on Jan 7, 2013 10:37 AM

    Edited by: user11141511 on Jan 7, 2013 10:43 AM

    Edited by: user11141511 on Jan 7, 2013 10:46 AM
  • 7. Re: how to use windows environment variable "%appdata%" in TEXT_IO built-in
    Christian Erlinger Guru
    Currently Being Moderated
    This
    user11141511 wrote:
    1 create or replace procedure toolEnv_value is
    2 tst varchar2(100);
    3 tst2 varchar2(100);
    4 begin
    5 Tool_Env.Getvar('appdt',tst);
    6 Tool_Env.Getvar('appdat',tst2);
    7 dbms_output.put_line(tst||user||tst2);
    8* end;
    SQL> /
    is a database procedure. tool_env is a forms package and thus not recognized by database PL/SQL. You need to declare your procedure in forms, not as a stored procedure.

    I missed the part where you said you are on 6i webforms; anyway; this
    SELECT SYS_CONTEXT ('USERENV', 'OS_USER') from dual
    will give you the OS User running the application server in webforms, not the client OS user the same way as tool_env.getvar will give you environment variables from the application server.

    If this is what you need then go for it; If you need the real client variables there is no way around java in forms 6i.

    See how to access environment variables in java: http://docs.oracle.com/javase/tutorial/essential/environment/env.html
    You'd simply need to write a java bean upon that.

    cheers
  • 8. Re: how to use windows environment variable "%appdata%" in TEXT_IO built-in
    Andreas Weiden Guru
    Currently Being Moderated
    will give you the OS User running the application server in webforms, not the client OS user the same way as tool_env.getvar will give you environment variables from the application server.
    And also TEXT_IO will open a file on the application server and not on the client.
  • 9. Re: how to use windows environment variable "%appdata%" in TEXT_IO built-in
    user11141511 Newbie
    Currently Being Moderated
    I'm already using TEXT_IO to write data file for user's "C" drive ( root drive ) or "C:\TEMP" folder on XP operating system.

    Sorry, I'm confused by
    "will give you the OS User running the application server in webforms, not the client OS user the same way as tool_env.getvar will give you environment variables from the application server "

    "And also TEXT_IO will open a file on the application server and not on the client."
  • 10. Re: how to use windows environment variable "%appdata%" in TEXT_IO built-in
    Andreas Weiden Guru
    Currently Being Moderated
    Do you run your forms as client/server? Or do you run forms in the web (using a browser)?
  • 12. Re: how to use windows environment variable "%appdata%" in TEXT_IO built-in
    Andreas Weiden Guru
    Currently Being Moderated
    Then the default.env - file is irrelevant to you. Its only used in webforms. Try Christian's suggestion
    tool_env.getvar('APPDATA', your_variable);
  • 13. Re: how to use windows environment variable "%appdata%" in TEXT_IO built-in
    Christian Erlinger Guru
    Currently Being Moderated
    You are obviously not familiar with the architecture of webforms. See here http://www.oracle.com/technetwork/developer-tools/forms/275632-133265.pdf

    I guess you are running your forms locally, so the forms server and the client run on the very same machine. This won't be the case once you run in production, as you will have an application server and clients connecting to the server.
    text_io, tool_env and all the forms built ins will be executed on the machine the forms runtime runs on, and in a 3 tier architecture this is the application server, not the client as the real client will run just a java applet which actually just does what the forms runtime on the server tells it to do (or passes client side events like mouse clicks to the forms runtime on the server).

    A very simple explanation for the architecture would be that the whole GUI part has been ripped off the forms runtime and put into a java applet; the logic part (the old-fashioned forms runtime) where the whole Forms PL/SQL code is executed communicates with the GUI part (which is implemented as a java applet) via HTTP, so there is no need to have both running on the very same machine.

    So if you are writing a file with text_io on c:\dummy.txt this file will be generated on the application server machine as it is executed where the forms runtime runs. If you read environment variables with tool_env.getvar you will get the environment variable from the application server machine.

    If you need those variables from your application server then those built-in packages are what you need, but if you need the real client variables there is no way around java in webforms 6i. But the beans should be simple enough to have them written within no time ;)

    cheers
  • 14. Re: how to use windows environment variable "%appdata%" in TEXT_IO built-in
    Christian Erlinger Guru
    Currently Being Moderated
    user11141511 wrote:
    forms on client/server
    Ah well, after all it's client server. You can forget my previous post ;)

    cheers
1 2 Previous Next

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points