Can I use a variable of environment inside a *.sql file?

Hello

I want to create an external table.
Then I use the command
create or replace directory abc as "C:\folder"... within a sql file.

Now, I want "C:\folder" way to be dynamic I use this path in many other places also inside the sql file. So I thought to create an environment variable and set this value. I tried using like %Path% but it gives error... where % PATH%=C:\folder.
Can I use a variable of environment inside a *.sql file?
But how to do it or is there another way.


Thank you
Olivier

Published by: user11018268 on February 19, 2010 01:03

You can use a variable substitution:

SQL> accept basedir prompt "input the base dir:  "
input the base dir:  c:\exp
SQL> create or replace directory exp as '&basedir';
old   1: create or replace directory exp as '&basedir'
new   1: create or replace directory exp as 'c:\exp'

Directory created.

SQL> create or replace directory exp_data as '&basedir\data';
old   1: create or replace directory exp_data as '&basedir\data'
new   1: create or replace directory exp_data as 'c:\exp\data'

Directory created.

SQL> create or replace directory exp_log as '&basedir\log';
old   1: create or replace directory exp_log as '&basedir\log'
new   1: create or replace directory exp_log as 'c:\exp\log'

Directory created.

SQL> select DIRECTORY_NAME, DIRECTORY_PATH
  2  from dba_directories;

DIRECTORY_NAME                 DIRECTORY_PATH
------------------------------ ------------------------------
EXP_LOG                        c:\exp\log
EXP                            c:\exp
EXP_DATA                       c:\exp\data

Max
http://oracleitalia.WordPress.com

Tags: Database

Similar Questions

  • WARNING: Incompatible Arg. You can't use stack Variables If generating series is not defined

    What does this message mean?

    "WARNING: incompatible Arg. you can't use stack Variables If generating series is undefined."

    Where can I put generate series only?

    Thank you

    Derek

    Hi Derek,.

    Not all LabVIEW C Generator settings are compatible with each other. In this case, you must define generate series only (aka 'disable parallel execution') If you want to generate the code uses the variable stack.

  • ORDS3.0EA can be used in a production environment

    Hello:

    I had planned to launch a project to deploy a Web service with ADR 2.0 and probably with Apex.

    But now ORDS3.0 EA was released. I can deploy without apex, and it has a function to simply deploy webservice.

    So now I need to decide whether to use ORDS2.0 or 3.0 in my project.

    EA can be used in a production environment? Can the project to have a month or two for the kickoff, if I have a question in the EA version, I raise a SR on EA version?

    Please consult the readme.html in the distribution, as he says it, EA builds are NOT supported for production use

  • Can I use a variable in a slider?

    Version of DB 10g
    Developer SQL 3.

    Hi once again, everything

    This post is a result of the post previous 'Sequence increment by 2 and not 1.'

    Here's a quick run down of what I do.
    We have historical records dating back decades and decades and decades (1900). Some of the most recent data were recorded in the worksheets. With some manipulation of data, it was possible to reorganize the data in its forms of entry in a flat file. These data were then imported into Access database, then using SQL Developer I made a data base for each access database connection and used copy for Oracle... tool to create a table in my flat file schema. In test data that I have right now that I copied the 5 access to Oracle databases and the results are five paintings called plot_84, plot_151 etc. I created a database that contains four main tables where the data from the flat files must be inserted, to standardize the it (I think the sentence is).

    I with the help of a large number has been able to train the following anonymous block, and it works very well (with the exception of the question of sequencing).

    DECLARE get_plot_measurement_id NUMBER;
    update_plot_measurements VARCHAR2(4000);
    get_tree_id NUMBER;
    get_plot_id NUMBER;
    
    BEGIN
        --1. Initiate insert process by getting PK from psp_plots
        SELECT plot_id INTO get_plot_id FROM psp_plots WHERE plot_name = 84; 
        
        --2. Insert records into psp_plot_measurements and keep relationship with psp_plots with variable get_plot_id.
        --   and get primary key value of psp_plot_measurements to insert into psp_tree_measurements during loop process.
        INSERT INTO psp_plot_measurements (plot_id) VALUES (get_plot_id) RETURNING plot_measurement_id INTO get_plot_measurement_id;    
        
        --3. Update record created at point 2.
        UPDATE psp_plot_measurements
           SET measurement_date    = (SELECT DISTINCT measurement_date FROM plot_84)
             , codominant_height   = (SELECT DISTINCT codominant_height FROM plot_84)
             , assessor            = (SELECT DISTINCT assessor FROM plot_84)
         WHERE plot_measurement_id = get_plot_measurement_id
         ; 
      
        --4. Open cursor to insert rows one at a  time and maintain relationships between related tables.
        FOR c1 IN
          (SELECT tree_number 
             FROM plot_84
          )
          
          LOOP      
        
            --5. Insert record into psp_trees
            --   and get primary key value of psp_trees to insert into psp_tree_measurements
            INSERT INTO psp_trees (plot_id, tree_name) VALUES (get_plot_id, c1.tree_number) RETURNING tree_id INTO get_tree_id;
        
            --6. Insert records into psp_tree_measurements and keep relationship with psp_trees with variable get_tree_id.
            INSERT INTO psp_tree_measurements (plot_measurement_id, tree_id) VALUES (get_plot_measurement_id, get_tree_id);
        
          END LOOP;
    
    END;
    /
    But me being someone who loves jobs mind numbing again and again, and more (about 1000 times x, who knows) still wants something I can preload a list of arrays of flat file (5 in this example) and just not run it.

    The problem is the following:
    Can I use a variable in a cursor, how are hilighted in bold below.

    "BOLD" has not worked is the bit of code FOR c1 IN (SELECT tree_number FROM plot_ | col_name_var) you will see just under point 4 below
    DECLARE p_column_num NUMBER;
    col_name_var VARCHAR2(30);
    type number_ptb IS table OF VARCHAR2(4000);
    p_column_nam number_ptb;    
    get_plot_measurement_id NUMBER;
    update_plot_measurements VARCHAR2(4000);
    get_tree_id NUMBER;
    get_plot_id NUMBER;
    
    BEGIN
    
        p_column_num := 5;
        p_column_nam := number_ptb();
        p_column_nam.extend(6);
    
        p_column_nam(1) := 84;
        p_column_nam(2) := 151;
        p_column_nam(3) := 152;      
        p_column_nam(4) := 214;
        p_column_nam(5) := 283;
    
        FOR loop_int IN 1 .. p_column_num
        LOOP
    
          col_name_var := p_column_nam(loop_int);
    
    --1. Initiate insert process by getting PK from psp_plots
          SELECT plot_id INTO get_plot_id FROM psp_plots WHERE plot_name = col_name_var; 
        
    --2. Insert records into psp_plot_measurements and keep relationship with psp_plots with variable get_plot_id.
    --   and get primary key value of psp_plot_measurements to insert into psp_tree_measurements during loop process.
          INSERT INTO psp_plot_measurements (plot_id) VALUES (get_plot_id) RETURNING plot_measurement_id INTO get_plot_measurement_id;    
        
    --3. Update record created at point 2.
          update_plot_measurements := '
          UPDATE psp_plot_measurements
             SET measurement_date    = (SELECT DISTINCT measurement_date FROM plot_' || col_name_var ||')
               , plot_size_10_30cm   = (SELECT DISTINCT plot_size_10_30cm FROM plot_' || col_name_var ||')
               , plot_size_30_50cm   = (SELECT DISTINCT plot_size_30_50cm FROM plot_' || col_name_var ||')
               , plot_size_50cm      = (SELECT DISTINCT plot_size_50cm FROM plot_' || col_name_var ||')
               , codominant_height   = (SELECT DISTINCT codominant_height FROM plot_' || col_name_var ||')
               , assessor            = (SELECT DISTINCT assessor FROM plot_' || col_name_var ||')
           WHERE plot_measurement_id = ' || get_plot_measurement_id
           ;
     
           EXECUTE IMMEDIATE update_plot_measurements;
      
    --4. Open cursor to insert rows one at a  time and maintain relationships between related tables.
          FOR c1 IN (SELECT tree_number FROM plot_|| col_name_var )   
              LOOP      
        
    --5. Insert record into psp_trees
    --   and get primary key value of psp_trees to insert into psp_tree_measurements
                INSERT INTO psp_trees (plot_id, tree_name) VALUES (get_plot_id, c1.tree_number) RETURNING tree_id INTO get_tree_id;
        
    --6. Insert records into psp_tree_measurements and keep relationship with psp_trees with variable get_tree_id.
                INSERT INTO psp_tree_measurements (plot_measurement_id, tree_id) VALUES (get_plot_measurement_id, get_tree_id);
        
              END LOOP;
      END LOOP;
      
    END;
    /
    Reviews on my welcome code.

    Ben

    Published by: benton on Sep 1, 2011 11:31

    Published by: benton on Sep 1, 2011 11:32

    Published by: benton on Sep 1, 2011 11:34

    with your current model, you need to write once for each table or write dynamic SQL regardless of the bulk of collect. adding most collect simply means you can do all the inserts in a single step and generally average performance benefits (see docco to COLLECT in BULK and for ALL).

    However, it is not really solve your problem.

    can I suggest an ETL step where you move all of the data in a table, then cross and run this function on all resulting?

  • A Reader Extended form can be used in a closed environment?

    Hello

    I have a question. A Reader Extended form can be used in a closed environment. It is a closed network, without an Internet connection.

    (Otherwise, I lost the last 6 months of my life...)

    K

    Yes, it can, especially if you use Reader 8 or 9.  There was some problems with earlier versions of the player that requires positive confirmation of the Reader Extensions credential with the CRL (CRL) list, which required that he had to go out on the web to retrieve the CRL.

    Depending on how deep you want your methodology of tests to do, that I would take a Virgin windows machine that does not drive on your computer, download or otherwise transfer your form and RE installation program and put offline.  Then install the reader and open your form.  It should open with additional rights without problem.

    But the main thing is that it is designed to work for your use case.

  • can we use repository variables in bi publisher as in answers

    can we use repository variables in bi publisher as in answers

    If possible, how

    Yes,

    but you should use Oracle BIEE as data source in order to use the variable in the repository

    you will need to follow the following syntax: valueof ("variable")

  • Conversion: Can I use Corel WordPefrect 8 data with Windows Vista files?

    Can I use data files Corel WordPefrect 8 with Windows Vista?

    On Friday, June 11, 2010 17:03:40 + 0000, grandmadfs wrote:
     
    > Can I use Corel WordPefrect 8 data with Windows Vista files?
     
     
     
    The issue here is not one of which version of Windows you are using.
    It is one of what you have installed applications.
     
    The answer is Yes, if you have WordPerfect (or some compatible)
    program) installed on Windows Vista. The answer is no, if you do not.
     
     
    Ken Blake, Microsoft MVP (Windows desktop experience) since 2003
     

    Ken Blake

  • How many times can I use a variable binding in a query of the VO?

    Is it possible that I can use a variable binding in a query of VO just once?

    I test a query that keeps throwing the Houston-27122 error by pressing the application module tester. I tried to limit the problem to the simplest possible case, and it seems that the error is caused by the fact that I use the same variable bind two or more times.

    When the query looks like this:

    query1.png

    I have run, enter 'x' and it returns me the result.

    When I change to:

    query2.png

    I have run, enter the value

    param.png

    and immediately get the error

    error.png

    The same thing in sqlplus runs without problem:

    sqlplus.png

    My version of JDev is build JDEVADF_11.1.1.9.0_GENERIC_150314.0718.6673

    Please, advise.

    P. S. where can I find documentation queries are supported in your? In particular, I'm interested if I can use WITH the clause. There seems to be some confusion on this matter (see, for example, Oracle SQL WITH clause support - JDeveloper and ADF)

    Thank you.

    It depends on:

    Open your VO in JDev and go the the query page.

    In the lower part, there is a drop down 'link type', it is usually set to "JDBC-positional. In this case, you will need to provide the bind value for each occurrence of the variable binding separately.

    You could change that to "named" (don't remember the exact name). But beware, this will also affect all relatioships master retail to others your. I think that this is not a good idea to change the style of binding to a single VO.

    Good bye

    DPT

  • Can I use session variables in data model BI publisher SQL query?

    Hi Experts,

    We apply security at the level of the BI Publisher 11g data.

    In OBIEE we do so using session variables, so I wanted to just ask if we can use the same session variables in BI Publisher as well
    That is, we can include a where clause in the SQL for the sample data as

    Where ORG_ID = @{biServer.variables ['NQ_SESSION.]} {[INV_ORG']}

    I would like to know your opinion on this.

    PS: We implement security EBS r12 in BI Publisher.

    Thank you

    Read this-> OBIEE 11 g: error: "[nQSError: 23006] the session variable, NQ_SESSION.» LAN_INT, has no definition of value. "When you create a SQL query using the session NQ_SESSION variable. LAN_INT in BI Publisher [ID 1511676.1]

    Follow the ER - BUG: 13607750 -NEED TO be able TO SET up a SESSION IN OBIEE VARIABLE AND use it IN BI PUBLISHER

    HTH,
    SVS

  • Can I use a variable, all referring to a text field?

    Hello

    I have to settle for some fields readOnly property DYNAMICALLY (I mean, until the moment of execution, I do not know which fields are read-only and which are not?  .

    So I want to replace the TextField1 dynamically with all the fields in the syntax below. So, can we put a variable in the position of TextField1? If so, how can I do that?

    xfa.resolveNode ("VISITOR. Page3.SubFrom1.TextField1') .access = "readOnly";

    xfa.resolveNode ("VISITOR. Page3.SubFrom1. MyVariableComesHere') .access = 'readOnly ';

    How can I put the variable in the Red position?

    In details:

    I have 5 fields, then I want to readOnly, then I hv to write as below,

    xfa.resolveNode ("VISITOR. Page3.SubFrom1.TextField1') .access = "readOnly";

    xfa.resolveNode ("VISITOR. Page3.SubFrom1.TextField2') .access = "readOnly";

    xfa.resolveNode ("VISITOR. Page3.SubFrom1.TextField3') .access = "readOnly";

    xfa.resolveNode ("VISITOR. Page3.SubFrom1.TextField4') .access = "readOnly";

    xfa.resolveNode ("VISITOR. Page3.SubFrom1.TextField5') .access = "readOnly";

    In fact, my requirement is differnent (I know at run time only... Wht wht fields I hv to set readOnly and wht wht fields should allow very good for entry), for this reason I want to use a VARIABLE in the 'position' of TextField1, TextField2... as bleow

    $myvariable var

    $myvariable = TextField1

    Closure of the TABLE

    xfa.resolveNode ("VISITOR. Page3.SubFrom1. myVariable') .access = 'readOnly ';

    Pls. Let me know I can sue a variable like this? If so, what is the correct syntax (pls.  Suggest me a free code to SYNTAX error, bcz am very very beginner to this)

    Thank you

    Thank you

    You can use the following...

    $myvariable var

    $myvariable = TextField1

    xfa.resolveNode ("VISITOR. (Page3.SubFrom1.' + myVariable + "") .access = "readOnly";

    Thank you

    Srini

  • Can I use a variable in step of TS Message for field 'waiting time '?

    Is it possible to use a variable (inhabitants, parameters, etc.) for the field "Wait time" in the stage of message TestStand?

    TestStand 4.1

    Thank you

    Rafi

    Go to the step settings > properties > Expressions > Expression Pre and enter something like:

    Step.TimeToWait = Locals.MyTimeToWait

  • Can I use a disc of recovery for transfers of files, data storage, etc.?

    Hello

    I bought 2 Z580 days back with windows 8. I did recovery disc on my drive external usb hard 250 GB using OneKey Recovery. Can I use tht same drive for file transerfers, store files, etc? Is it possible to make the recovery disc for win8?

    I keep a copy of the okr system recovery backup files in my external hard drive and other files. As far as I KNOW, there is only one program in a usb flash drive that will create the partitions without operating system. No DVD.

  • How can I use applescript for OCR to a bunch of files - with Acrobat XI?

    Hello

    IWant to write an AppleScript (for example) that can be used as a droplet or has a menu to open a folder of pdf files scanned for OCR. And - I want to use Acrobat XI (because it's my version), German version.

    As Acrobat XI is not recordable with applescript editor and I can't find a manual of objects and methods I googled a script that worked with Acrobat 9, but not with Acrobat XI. Here, you define a "Wizard of Action" - Script for example called "OCR this ' and 'click' of the element. But as in Acrobat XI this Item is noch in hand-sbubmenu more than it seems to not work.

    Here is a screenshot:

    Bildschirmfoto 2014-07-14 um 10.57.06.png

    And it's theapplescrpt, tha opens "Aktionsassistent":

    Click on the menu item "Aktionsassistent" in the menu "Tools" from menu item "Tools" in the menu "Anzeige" of the menu bar item "Anzeige" from the menu bar 1

    BotR, so I cannot reach "OCR it."

    If any body has a suspicion - either by clicking on "OCR this ' or sript an OCR on one open our AppleScript, that would be great.

    Thank you

    Smail

    AppleScript is documented in the Acrobat SDK kit. But there is no way to do it.

  • Can we use & in the commented code from PL/SQL?

    I used & in the commented block of PL/SQL when I compile it Toad, it was compiled, but it had not when I compile SQL * why?


    SQL > declare
    2 v_number number;
    3. start
    4 / * this called abc and xyz procedure * /.
    5 zero;
    6 end;
    6 N
    Enter the value for xyz:

    in SQL * more type:

    SQL> set define off
    

    to stop prompting substitution variables.

  • Cannot use the variable of environment with the API. DataWindow.Utilities.mShellAndWait

    When you run the following command in an event FDM script, an error occurs. If I specify the direct path (i.e. "D:\Oracle\Middleware\EPMSystem11R1\products\Essbase\EssbaseClient\bin\startMAXL.cmd") the error does not occur. But if I open the command prompt and enter the path by using the environment variable (as in the script below), the MaxL script runs fine. It seems that causes an error when executed by API. . DataWindow.Utilities.mShellAndWait's - someone please have any suggestions as to how I can fix this?


    Error:
    Error: File not found
    Online: 77


    Script:
    «Call MaxL script to perform data clear the calculation.»
    Set objShell = CreateObject ("WScript.Shell")
    strCMD = "%EPM_ORACLE_HOME%\products\Essbase\EssbaseClient\bin\startMAXL.cmd" & strFilePath & ".mxl.
    API. DataWindow.Utilities.mShellAndWait strCMD, 0

    I don't think that vbScript will solve strCMD = "%EPM_ORACLE_HOME%\products\Essbase\EssbaseClient\bin\startMAXL.cmd" & strFilePath & ".mxl" correctly. I think that the environment variables can be solved in the interface. FDM is probably literally including the string "% EPM_ORACLE_HOME" in the path.

    If you share (read and execute) the file on the Essbase server that contains startMAXL.cmd (or containing a record of the ancestor of this folder), you can use the UNC path: strCMD = "------------"& strFilePath & ".mxl"»

    However, if startMAXL is installed on the server, FDM, you can use the local path to startMAXL.cmd.

Maybe you are looking for