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?

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.

  • 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")

  • 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

  • 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

  • Use of Variables in multiple slides

    I use a text entry box to save the information.

    I want the user to repeat this information in a future slide to get a match. I have created the script for this action.

    But, I want the user to see what they typed in the first tex input box without going back on this slide on the second slide. As a hint.

    Is the way they do?

    Thank you

    Hello

    Perhaps you know that each TEB has an associated variable (better give a more meaningful call than the default one). I could you offer workaround to show the value of this variable, but think that the simplest solution is to get a copy of the improved ETB, a widget created by Jim Leichliter, AKA CaptivatePro. Here is the link:

    Ext-of-a-text-entry-box-TEB/ http://captivatedev.com/2010/09/08/Adobe-Captivate-widget-using-variables-in-the-default-t

    A ride on its site, it has many improved widgets to display variables associated with the TextArea widgets, checkboxes and radio buttons as well.

    Lilybiri

  • How can we use the variables name, for example?

    I use 9 textbox in my step. The names are similar, only difference is the last character. (s1_0, s1_1, s1_2,...). I am using these textbox in a loop. But I couldn't find the right typing... s1_ [i], (i) s1_ or s1_ {i} gives an error.

    s1_0.text = 0
    s1_1.text = 0
    s1_2.text = 0
    s1_3.text = 0
    s1_4.text = 0
    s1_5.text = 0
    s1_6.text = 0
    s1_7.text = 0

    How can he do the shortest hits for this problem?

    Use the operator [] table:

    for (var i: uint = 0; i<>

    This ["s1_" + i.ToString ()] .text = 0;

    }

  • Can OBIEE use Bind Variables?

    I doubt that it would be used for warehouse queries, but I'm the question arises. Has anyone used in OBIEE?

    [Here is a brief summary about them. | http://www.akadia.com/services/ora_bind_variables.html]

    I checked with the support of Oracle and it's official - OBIEE does not support the bind variable.

  • Can we use repository variables in the SQL statement of the guest of the column?

    Hi guys,.
    This is the query
    SELECT '-End Date '. " End year"OF"The consumer sector"WHERE ("-End Date "." ") End of year' = valueof (current_year)) or ("-End Date". "") (Year-end' = valueof (current_year) - 1).
    When you use this sql prompt of criteria being of error.
    Please suggest.

    Thanks.Sri

    Appreciate if you score as correct on the suggestion

    Also your old messages, at least let us know your comments ;)

  • Limit set using the variable

    IAM having the following query to load the data of my DataModel

    DataSource {
                id: firstSource
                source: "db/duDatabase.db"
                query: "SELECT title FROM how_to ORDER BY howToId ASC limit 10"
                onDataLoaded:
                    {
                        firstModel.insertList(data);
                    }
               }
    

    My Question is:

    How can I use a variable to set the limit in the query

    That is to say, I want something like that

     query: "SELECT title FROM how_to ORDER BY howToId ASC limit variableName"
    

    Please please help me. IAM stuck here.

    query: "SELECT title OF how_to ORDER BY howToId limit of ASC"+ NomDeLaVariable"

  • Use of variable in the For-Each statement

    Hello gurus.

    I'm having a problem using a variable, I created in a statement for each. Here is the code I am using
    My goal is to create a variable based on the type of Bill. If the invoice is a proof or a reprint, a copy should be printed. If it's a final bill, I need two copies.

    <? xdoxslt:set_variable($_XDOCTX,_'x',_0)? >
    for each<? If: Print_Additional_Header_Text_ID238 = "PROOF"? > <? xdoxslt:set_variable($_XDOCTX,_'x',_1)? > <? end if? >
    <? If: Print_Additional_Header_Text_ID238 = "REPRINT"? > <? xdoxslt:set_variable($_XDOCTX,_'x',_1)? > <? end if? >
    <? : otherwise (Print_Additional_Header_Text_ID238)? > <? xdoxslt:set_variable($_XDOCTX,_'x',2)? > <? end if? >
    <? xdoxslt:get_variable($_XDOCTX,'x')? > <? for-each@section:xdoxslt:foreach_number($_XDOCTX,1,$x,1)? >

    foreach is the loop that I use to repeat sections of the Bill.

    When I run with the last impression for each preview, I get an error that says "undefined variable: 'x'"»
    But when I remove the last for each good variable, 1 or 2, will show in the invoice.

    My question is: How can I use the variable 'x' in <? for-each@section:xdoxslt:foreach_number($_XDOCTX,1,$x,1)? >

    TIA
    Darius

    Published by: 852460 on May 24, 2011 08:31

    Published by: DEK17 on July 20, 2011 13:15

    Probably, this will help you

    http://winrichman.blogspot.com/search/label/multiple%20copy

    Try

    
    or
    
    
  • Using global variables

    Dear all.

    I created a global variable in the Init as an attachment.

    variables.JPG

    --------------------------------- Code ---------------------------------

    var total = 0;

    .

    .

    .

    .

    function Xxx() {}

    Total = total + 10

    App.Alert (total);     = > 10

    }

    ---------------------------------------------------------------------------

    When I call Xxx(), alert to function Xxx() 10;

    in the click event of the button on the next page, I tried to call total variable (global variable).

    --------------------------------- Code ---------------------------------

    App.Alert (total);       = > error?

    App.Alert (init.total);  = > 0

    ---------------------------------------------------------------------------

    How can I use global variable?

    To get the value of the Init variable, you would use Init.value

    Paul

Maybe you are looking for