Can i use a environment variable inside a *.sql file?

Hello,
I want to create a external table.
So i am using the command
create or replace directory abc as 'C:\folder'.... inside a sql file.
Now i want the path "C:\folder" to be dynamic as i am using this path in many other places also inside the sql file.So i thought to create a environment variable and put this value there.I tried using as %PATH% but it gives error..... where %PATH%=C:\folder.
Can i use a environment variable inside a *.sql file?
But how to do that or is there any other way.
Thanks
Swapna
Edited by: user11018268 on Feb 19, 2010 1:03 AM

user11018268 wrote:
Actually what i want is the path "C:\folder" is not fixed it can be anything which i may not know the user may decide it later. Not supported. A directory object refers to a specific physical location (directory/folder) on a file system. Not a path.
You can work around it by (creating and) using a function (running under a super user schema with authid definer privs). The caller (e.g. schema scott ) calls it with a physical path. E.g. GetDirectoryObject( 'C:\folder\2010\feb\week4' ).
This function determines if there is an existing directory object for the path. If not, it uses a wildcard search to determine if there are any directory objects for parents in the path (e.g. for C:\folder\2010\feb or C:\folder\2010 or C:\folder ).
If it finds a directory object, it interrogates the data dictionary to determine if the caller, schema scott for example, has read/write access on that directory object. If it has, it creates a new directory object and grants the caller read/write access to it. The function then returns the name of the directory object to the caller.
The caller thus do not deal directly with directory objects. The function returns the object name given a physical path as input. Also, only a single base directory needs to be created (e.g. for C:\folder ) and access granted to the schema on it. Any sub-directory in that base directory can now be dynamically accessed by the schema.

Similar Messages

  • Apache Environment Variables inside PL/SQL

    How to access Apache Environment Variables inside HTMLDB (PL/SQL block)?

    Hi,
    You can use the owa_util.get_cgi_env packaged function -
    FUNCTION GET_CGI_ENV RETURNS VARCHAR2
    Argument Name                  Type                    In/Out Default?
    PARAM_NAME                     VARCHAR2                INSo, pass in the name of the Env var you want and it will give you back the value.

  • How can I use a public variable inside a CachedResultSet

    The public variable that I declared cannot be called inside the CachedResultSet class....
    Heres a part of the code:
         public String type;
         public String getType()
             return type;
         public void setType(String s)
             type = s;
         public CachedRowSet first_report(){
              try {
              String t=type;<<it cannot get the String type declared outside.....     
              Statement stmt = con.createStatement();
              String query = "select stock_code, shares_prices, new_shares, trans_date, prev_close from allTrans where name_broker='"+type+"' order by stock_code";
              ResultSet rs = stmt.executeQuery(query);
                CachedRowSetImpl crset = new CachedRowSetImpl();
                crset.populate(rs);
              rs.close();
              stmt.close();
              con.close();
              return crset;
               catch (Exception e)
              {   System.out.println(e.getMessage());
                  return null;
         }

    I am not getting any error but the value of String type is null when entering the CachedRowSet...I don't know why it is null and yet the String type can be used by other classes...Like the getType...
    Heres the code:
    import java.sql.*;
    import sun.jdbc.rowset.*;
    import com.sun.rowset.*;
    import javax.sql.rowset.CachedRowSet;
    public class views
          String url, uname, pwd;
          Connection con;
         public String type;
          public String hstock;
          public String hbroker;
         public String getType()
         {  System.out.println("get:"+type);
             return type;
              public void setType(String s)
             type = s;
         public views()
               try
               Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
               url = "jdbc:odbc:***";
               uname = "root";
               pwd = "yes";
               con = DriverManager.getConnection(url, uname, pwd);
               } catch (Exception e)
                    System.out.println(e.getMessage());
    public CachedRowSet first_report(){
              try {
              String t=type;
                System.out.println(t);
                System.out.println(type);     
              Statement stmt = con.createStatement();
              String query = "select stock_code, shares_prices, new_shares, trans_date, prev_close from allTrans where name_broker='"+type+"' order by stock_code";
              ResultSet rs = stmt.executeQuery(query);
                CachedRowSetImpl crset = new CachedRowSetImpl();
                crset.populate(rs);
              rs.close();
              stmt.close();
              con.close();
              return crset;
               catch (Exception e)
              {   System.out.println(e.getMessage());
                  return null;
         }

  • Error Setting Environment Variable inside Listner.ora

    Hi,
    I am trying to set an environment variable inside listner.ora as follows
    (ENVS="EXTPROC_DLLS=ANY,LD_LIBRARY_PATH=/opt/app/oracle/product/9.2/lib32:/opt/app/oracle/product/9.2/network/lib32:/usr/lib:/usr/X11R6:/usr/dt/lib,LIBPATH=/opt/app/oracle/product/9.2/lib32,MQSERVER=SYSTEM.DEF.SVRCONN/TCP/ashsou03.mcilink.com(4444)")
    but every time I try to start the listner it gives me the following error:
    TNS-01155: Incorrectly specified SID_LIST_LISTENER parameter in LISTENER.ORA
    NL-00303: syntax error in NV string
    I think that the parenthses, (4444), in the MQSERVER value is causing this. Any ideas on how I can configure it?

    Hi
    Very many thanks for ur solution.. i actually hadset the environment variables spacce..but when i execute the autoexec.bat file i dont get any error(out of env space)..but when i run the startup.bat file i get from the command prompt, i get the foll error.
    This is my Autoexec.bat
    SET JAVA_HOME=D:\Jkit\bin
    SET CATALINA_HOME=D:\tomcat\jakarta-tomcat-4.1.29\bin
    SET PATH=D:\Jkit\bin;C:\WINDOWS;C:\WINDOWS\COMMAND;
    SET PATH=%PATH%;C:\PROGRA~1\COMMON~1\AUTODE~1;
    THE FOLLOWING IS THE ERROR I GET WHEN I RUN STARTUP.BAT UNDER TOMCAT'S BIN UNDER THE COMMAND PROMPT
    D:\tomcat\jakarta-tomcat-4.1.29\bin>startup
    Syntax error
    Out of environment space
    Out of environment space
    Out of environment space
    Using CATALINA_BASE: D:\tomcat\jakarta-tomcat-4.1.29
    Using CATALINA_HOME: D:\tomcat\jakarta-tomcat-4.1.29
    Using CATALINA_TMPDIR: D:\tomcat\jakarta-tomcat-4.1.29\temp
    Using JAVA_HOME: D:\Jkit
    Out of environment space
    Out of environment space
    Invalid switch - -DJAVA.ENDORSED.DIRS=D:\TOMCAT\JAKARTA-TOMCAT-4.1.29\COMMON\ENDORSED
    I even set JAVA_HOME AND CATALINE_HOME to the \bin dir respectively..
    still i get the same error
    As given under the tomcat installation documentation (RUNNING.txt), i set the space for environment space under the Memory tab, for startup and shutdown.bat files, it creates a shortcut for running the resp .bat files, running startup.bat file i get,CATALINA_HOME VAR HAS NOT BEEN SET PROPERLY, THIS OCCURS FOR BOTH TOP LEVEL DIR SETTING AND /bin DIR SETTING of CATALINE_HOME IN autoexec.bat
    PLEASE HEL, I HAVE BEEN TRYING TO CONFIGURE IT FOR THE PAST DAYS BUT WITH NO SUCCESS, DONT KNOW WHERE I AM GOING WRONG..PLEASE HELP

  • Accessing shell environment variables inside OMBPlus script

    Hi,
    I have a problem accessing an environment variable inside OMBPlus script. I can 'see' the env. var values when using tclsh, but when I use OMBPlus.sh it doesn't work?
    Anybody has an example of how to do this?
    For example: puts $::env(MYVAR)
    Thanks,
    Ed

    Hello!
    Issue the command:
    puts [array names env];
    this will print you the content of the env array which is definitely not the environment variables.
    If you want your environment variable appear in the env tcl variable then you must edit the ombplus.bat file and pass it through a java option like this:
    -DMYENV="%MYENV%" (on windows assuming you declared MYENV).
    Now puts $env(MYENV) will work.
    Regards,
    Robert

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

    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

    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

  • Using BASH environment variables in xCode build configuration

    Hi All,
    Is it possible to use BASH environment variables (exported from /etc/profile, for example) in xcode build settings?
    Specifically, I am exporting a "BOOST_HOME" variable, and would like to referencing this variable in "User Header Search Path", but the obvious $BOOST_HOME doesn't seem to work?
    Thanks,
    Andrew

    I don't know much about XCode -- but to set environment variables for GUI applications you need to edit ~/.MacOSX/environment.plist. There's a description here:
    http://wiki.lyx.org/Mac/Environment
    After editing that file I believe you have to logout and back in for the changes to take effect.
    I swear I saw a GUI app to help edit that file, but I can't find it now...

  • Using a environment variable that was created during the Task Sequence process - SCCM 2012 R2

    Hi,
    I'm triyng to use a environment variable that is create in the beginning of the Task Sequence.
    1. I'm using a VBScript that get the Exit Code of an application, and create the environment variable "iReturn" with the value of the exit code. (This is working)
    2. I add this variable in the CustomSettings.ini, like this "iReturn=%iReturn%
    3. After the step that I run the VBScript I put the "Gather" step to get the variables, but looking in the BDD.log the iReturn variable appears the same as the CustomSettings.ini configuration "iReturn=%iReturn%". (But, if I put a "Restart
    Computer" step after the VBScript, the BDD.log shows the iReturn variable with the right code.)
    Question: How can I update the environment variable of Windonws XP to use in the Task Sequence without restart.
    OR
    How can I configure autologon in SCCM 2012 (if have no way to update withou restart computer).
    I already tried the autologon with registry settings and a specific user, If I starts the process with this user works, but If I starts the process with other user, after the autologon the process doesnt continue, I have to do logoff and login with the user
    that I started the process.
    PS: All this steps have to be executed before the WinPE phase. 

    Environment variables must be explicitly set every time a system boots so unless you have a process to repopulate it after the reboot, it won't persist automatically.
    Why not store the value in a task sequence variable so that it persists after a reboot?
    Jason | http://blog.configmgrftw.com | @jasonsandys

  • Use environment variables in logging.properties file

    is there a way to use environment variables in logging.properties file?
    like this -
    java.util.logging.FileHandler.pattern = {$MY_BASE_LOG_FOLDER}/myapp1/log/123%g.logdo I have to write a custom logging.properties loader? if yes, then are there any examples on this?

    I'm sorry, but don't you think your answer is useless?
    Maybe I haven't made my question clear enough. I need to know if java.util.logging recognizes environment variables in logging.properties files.
    If it does not, then there should be a well-known class to use instead of standard loader for logging.properties (java api mention one briefly).

  • Within JBuilder, Reading Environment Variable From a BATCH File

    Hi ppl:
    Following my scenario without JBuilder. I would like to be able to do the same with JBuilder, so that I can run my application from within.
    1. In the DOS window, I run a config.bat file that sets up a whole bunch of environment variables and then calls another script file that sets up another whole bunch to set up environment for a third party API (C++ based).
    2. My application uses native methods to call the third party API which uses the environment variables set in step 1.
    I know how to set the environment varialbes in JBuilder (Project Parameters, VM). However, I don't know how I can call a batch file that does the same. I don't want to set up the third party variables in JBuilder manually, since the script that sets them up checks on a few things to customize the environment.
    I also know how to run a batch file from JBuilder, but that does not set the environment for the application. It seems like the batch file is run in a separate process.
    Any ideas?
    Kamran

    It seems like the batch file is run in a separate process.Yes, it is. That's a design feature of Windows. The environment variables that a process creates are available to any subprocess, but when the process ends, the environment variables vanish. That's because they are part of the process, not global variables as you might wish.
    So that's why your non-JBuilder scenario works; your C++ program is running in a subprocess of the process that defined the environment variables. And your JBuilder scenario doesn't work because the batch file it runs is in a process whose parent process is Windows, not JBuilder.

  • How to pass Unix environment variable to a SQL procedure or SQL * Plus

    Can any body suggest me how to ,
    How to pass Unix environment variable to a SQL procedure or SQL * Plus file..
    I am trying to invoke a SQL Procedure from Unix
    by passing the value of a Unix environment variable.
    Is it possible..?
    Thanks in advance.
    Regards,
    Srinivas Jaltaru

    Within your shell script you can use what is known as a "here document" which is basically a way of wrapping a call to Oracle. The following call to Oracle loops and writes rows to files with numerically increasing file names. Two unix shell variables are used, one in a select statement and one in a spool command :
    <pre>
    #!/bin/bash
    export ORACLE_SID=DEV05
    FILENO=1007351
    while [ ${FILENO} -le 1008400 ]
    do
    FILENAME=farm_${FILENO}.txt
    DUMMY=`sqlplus -s user20/user20 <<SQLSTOP
    set lines 73
    set pages 0
    set head off
    set termout off
    set echo off
    set feedback off
    select rpad(searchx, 8)
    from blastx@PRODUCTION
    where searchx = ${FILENO} ### here's a shell variable
    spool /export/home/user20/sql/psiblast/BACKUP2_D/${FILENAME} ### here's a shell variable
    spool off
    SQLSTOP`
    FILENO=`expr ${FILENO} + 1`
    done
    exit 0
    </pre>

  • How can I use time machine to recover my iWeb09 files?

    I read that iWeb stores one's website pages in the domain folder which can be located at ~/Library/Application Support/iWeb. Can I use time machine to recover my iWeb09 files? If so, how? -I tried. I entered my Time Machine back up, and went back in time and brought the domain file forward but it opened only my current site pages, not the ones I am trying to recover. And it says the Domain file was last modified in October 2007 which is crazy because I've been using iWeb a lot and have published many pages. It seems like the uncorrupted pages, which I am trying to recover, existed somewhere on my computer at one point in time and space, less than a week ago, becuse I just published my site to a new hosting service since Apple will soon stop web hosting. So why can I not find them using time machine?

    I continued searching and read another person's advise to down load an app named "Find File," then search for .sites. She said spotlight doesn't always find all files. So I did and sure enough, when I searched for .sites I found another Domain package, which I have no idea how it was created but which, it ends up, was the one actually being used by iWeb. So I went to that package then did the time machine and went back to before my web pages became corrupted. I had to delete corrupt blog pages out of my website menu to get iWeb to upload the other page changes even to a local folder.
    So I went to that newly found Domain, went back in time, then brought that forward and as you pointed out the domain package had the parts of the pages, the files and jpegs, but not the structure/layout of the pages. So, I guess I gave up on finding the old pages.
    Those pages still exist on the Apple hosting server but iWeb doesn't not reverse publication. Cyberduck would bring back the files and bits and peices but again not the pages as a total entity. I'm preparing for the end of Apple website hosting (next month?) and am republishing my old site. I decided to use a new domain name. So my entire original site is still totally intact on the web under the original domain name, on my mobile me site, I guess it will be there till sometime in June?
    My problems started when I tried to publish my website to the new server. It just would not publish the whole website in one session. So I decided to do it a few pages at a time. Some pages went up, but as I added more, for some unknown reason the, blog pages, (about 70 subpages),  which had aleardy uploaded just fine to the new server, became corrupt and locked up iWeb. Of course once I deleted the corrupt pages I didn't want to continue publishing the site to the host until I found and reinserted uncorrupted pages, knowing publishing changes would delete the already published pages.
    At first I thought it was the hosting server's fault, but when I discovered that it wouldn't publish even to a local fold I was able to locate the cause within iWeb, deleted those pages then tested by publishing to a local folder. iWeb worked locally, so I knew I had found the problem pages. Well this is way more than you wanted to know. Thanks for your advise but I'll just start the blogging pages over.

  • Want to use presentation date variable in Advance SQL filter option

    Hi,
    I want to use presentation date variable in Advance SQL filter option.....I am getting the below error.
    SQL in Advance SQL filter ----
    "Fact Status Details"."Load Date" =
    (select min(Cast("D Time"."Business Date" as char))-1
    from "D Time" where "D Time"."Operational Month Sk" =
    (select "D Time"."Operational Month Sk" from "D Time" where date '@{Date1}'=cast("D Time"."Business Date" As char)))
    Error ---
    Error getting drill information: SELECT "Fact Status Details"."Load Date" saw_0 FROM "Pre RFAI Sales" WHERE "Fact Status Details"."Load Date" = (select min(Cast("D Time"."Business Date" as char))-1 from "D Time" where "D Time"."Operational Month Sk" = (select "D Time"."Operational Month Sk" from "D Time" where date '@{Date1}'=cast("D Time"."Business Date" As char)))
    Error Details
    Error Codes: YQCO4T56:OPR4ONWY:U9IM8TAC:OI2DL65P
    Odbc driver returned an error (SQLExecDirectW).
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 27002] Near <select>: Syntax error [nQSError: 26012] . (HY000)
    SQL Issued: {call NQSGetLevelDrillability('SELECT "Fact Status Details"."Load Date" saw_0 FROM "Pre RFAI Sales" WHERE "Fact Status Details"."Load Date" = (select min(Cast("D Time"."Business Date" as char))-1 from "D Time" where "D Time"."Operational Month Sk" = (select "D Time"."Operational Month Sk" from "D Time" where date ''@{Date1}''=cast("D Time"."Business Date" As char)))')}
    Load Date format ---YYYYMMDD
    Please advise...i need to fix this issue urgently.

    Thanks for your reply.
    Could you please help me with the correct code...i tried to correct it....
    "Fact Status Details"."Load Date" =
    (select Cast(min("D Time"."Business Date" )-1 as char)
    from "D Time" where "D Time"."Operational Month Sk" =
    (select "D Time"."Operational Month Sk" from "D Time" where Date'@{Date1}'=cast("D Time"."Business Date" As char)))
    Please let me know if i am wrong..this code is also not working.

  • Can i Use two qery hints in one SQL(Oracle)?

    Hi,
    Can i Use two Query hints in one SQL(Oracle)? USE_HASH and No_Merge
    Thanks

    user10916886 wrote:
    Can I use like
    /*+ USE_HASH(X,Y) NO_MERGE(X) */
    will this work?Not really: NO_MERGE relates to mergeable views, not base tables. So whilst the USE_HASH may result in a hash join between the tables X and Y, USE_MERGE will be ignored for X.
    As hoek says, however, HINTs should be a last resort only, and if they're to be used at all you're best to stay with those that don't involve explicit objects, like ALL_ROWS, FIRST_ROWS_10, etc.
    user10916886 wrote:
    Im my database, if i don't use query hints. The expalin plan uses Nested loops, hence the query takes a lot of time.You would be better trying the ALL_ROWS hint here, instead of USE_HASH.
    Edit
    The optimizer, however, will have chosen NESTED LOOPs where it did because it believed that to be the most efficient data retrieval path with the information that it had to hand. So, if your statistics are comprehensive and up-to-date, yet the optimizer is continually opting for the less efficient plan, there's something else wrong, and HINTs are only masking that problem in the short-term.

  • Can I use the `deny` statements is a SQL database

    I have a web-app that I will need to scale to large proportions. In this web-app, I have a database in which some clients should not have access to specif tables. Can I use `deny` statements on an Azure SQL databases? Like this:
    deny select on a_table to a_user

    Hi James,
    Yes you can use DENY statements. Please see
    this link for more information on the usage of DENY statements.
    Thanks
    Silvia Doomra

Maybe you are looking for

  • Number of elements - Dimensional Hierarchy

    Hi, In a *'Dimensional Hierarchy'*, while creating a new *'Parent level'*, a 'Logical Level' dialogue box prompts for entering *'Number of elements at this Level'*+. What is its significance ? What is achieved by+ *'Number of elements at this Level'*

  • Loading multiple consecutive .swf files in Flash 8

    I have a question and hope that someone may be able to help; this might be a piece of cake for you... I have a container .fla movie and would like to load consecutive external .swf files. Right now I have a play button triggering the loading of the n

  • Oracle Database Administartor Training

    Dear All, Can anyone help me in finding a online training for Oracle Database Administrator for Oracle 10g on OPN Competency Center website. I have founded one but it is for Oracle 11g Databases. Kindly help me in finding this training. And I think t

  • Safari constanly crashes please help!

    Safari constantly crashes with no warning. I have not been able to figure out why. I have submitted the crash report multiple times, but now want to try and fix it myself. I am a newbie in terms of technical knowledge/troubleshooting so thanks to any

  • Installing SQL on OS 10.6.3

    I am interested in working with SQL in a very limited fashion so that I can assist my company as it tries to transition from a DOS based database to SQL. Curiosity and desire to learn is my motive. On the internet I've been floundering in terms and o