In BULK COLLECT with loop for?

Let's say I have a table with a column number and a date column.

I also have a query using a number and a date as a parameter. I want to run this query for each row in the table (using the column date and number of lines as parameters). If my thinking is looping through the rows and the query parameters for each line. It becomes a large number of queries select. Is it possible to use bulk collect here? All the examples I've seen where he uses a predefined cursor. Also, I don't know how to fix this problem without a cursor.

Here's the query I want to do for each line:
select * from reading_values rv, 
    (select * from 
       (select id, datereading
              from readings,
              where datereading < p_date and pointid = p_id
              order by datereading desc)
       where rownum <= 1) t
     where rv.reading_id = t.id

After reading your initial statement 3 times I simply add a third table to select it. I call this tableX colb and two columns cola (number) (date).

select rv.*, r.*, row_number() over (partition by r.pointid  order by r.datereading desc) rn
from reading_values rv
join readings r on rv.reading_id = r.id
join tableX x on x.colA = r.pointid and  r.datereading < x.colB
order by  r.pointid, datereading desc

You can restrict which to return only one row for each data point by using the column rn I already added.

select * /* probably need sinlge column names here to avoid duplications */
from (
   select rv.*, r.*, row_number() over (partition by r.pointid  order by r.datereading desc) rn
   from reading_values rv
   join readings r on rv.reading_id = r.id
   join tableX x on x.colA = r.pointid and  r.datereading < x.colB
)
where rn = 1
order by pointid, datereading desc

Published by: Sven w. on June 23, 2010 16:47

Tags: Database

Similar Questions

  • Bulk collect with sequence Nextval

    Hello


    Oracle Database 10 g Enterprise Edition Release 10.2.0.4.0 - 64 bit


    Had a doubt about the collection in bulk with nextval sequence. You need to update a table with a sequence of Nextval.

    where should I place select below in the proc is this before or after the loop


    < font color = "red" > SELECT prop_id_s.nextval INTO v_prop_id FROM dual; < / make >
    CREATE OR REPLACE PROCEDURE  (state IN varchar2)
    AS
       
       CURSOR get_all
       IS
          SELECT                              /*+ parallel (A, 8) */
                A .ROWID
                from Loads A WHERE A.Prop_id IS NULL;
    
       TYPE b_ROWID
       IS
          TABLE OF ROWID
             INDEX BY BINARY_INTEGER;
    
       
       lns_rowid          b_ROWID;
    BEGIN
    
    
       OPEN Get_all;
    
       LOOP
          FETCH get_all BULK COLLECT INTO   lns_rowid LIMIT 10000;
    
          FORALL I IN 1 .. lns_rowid.COUNT
             UPDATE   loads a
                SET   a.prop_id= v_prop_id (I)
              WHERE   A.ROWID = lns_rowid (I) AND a.prop_id IS NULL;
    
          
          COMMIT;
          EXIT WHEN get_all%NOTFOUND;
       END LOOP;
    
       
    
       CLOSE Get_all;
    END;
    /
    Published by: 960736 on January 23, 2013 12:51

    Hello

    It depends on what results you want. All updated rows would take the same value, or should all get unique values?

    Whatever it is, you don't need the sliders and loop. Just a simple UPDATE statement.

    If each line requires a unique value of the sequence, then

    UPDATE  loads
    SET     prop_id     = prod_id_s.NEXTVAL
    WHERE     prop_id     IS NULL
    ;
    

    If all the lines that have a need to the same value null, then:

    SELECT     prod_id_s.nextval
    INTO     v_prop_id
    FROM     dual;
    
    UPDATE  loads
    SET     prop_id     = v_prop_id
    WHERE     prop_id     IS NULL
    ;
    

    Don't forget to declare v_prop_id as a NUMBER.

    I hope that answers your question.
    If not, post a small example of data (instructions CREATE and INSERT, only relevant columns) for all the tables and the involved sequences and also publish outcomes from these data.
    If you ask on a DML statement, such as UPDATE, the sample data will be the content of the or the tables before the DML, and the results will be the State of the or the tables changed when it's all over.
    Explain, using specific examples, how you get these results from these data.
    Always say what version of Oracle you are using (for example, 11.2.0.2.0).
    See the FAQ forum {message identifier: = 9360002}

  • In bulk vs cursor loop for

    Hello

    I'm on a mission :)

    I want to convince our development department to encourage loose on cursor for loops. But it is more difficult to do what I expected. Just a link to many Web Sites with well-known people, saying ' use in bulk "is not enough. So, I'm going to create a unit test that measures the difference.

    But 11g (also 10g) is smart. Simple test cases are converted. Oracle ignores the cursor for loop and do as a statement in bulk. What can I do against it without changing the settings?

    Here's a test case:
    drop table art_test;
    
    CREATE TABLE art_test 
    (
      ber     NUMBER(2),
      agr     NUMBER(2),
      wgr     NUMBER(2),
      art_no  NUMBER(4)
    );
    
    
    insert into art_test 
    SELECT 10,10,10,level FROM dual
    connect by level < 10000;
    create or replace
    package bulk_test authid definer as 
    
      procedure single_test_simple;
         
         procedure bulk_test_simple;
      
      FUNCTION artnr  ( 
                      bereich IN pls_integer,
                      wg      IN pls_integer,
                      ag      IN pls_integer,
                      art     IN pls_integer
                    )
      return varchar2;
    end bulk_test;
    /
    
    create or replace
    PACKAGE body bulk_test
    AS
    PROCEDURE single_test_simple
    AS
    
         v_artnr VARCHAR2 (10) ;
      v_rows number default 2000;
    
    
    BEGIN
    
         EXECUTE immediate 'alter session set tracefile_identifier=''single_simple''';
         dbms_monitor.session_trace_enable (NULL, NULL, TRUE, TRUE) ;
    
         FOR rec IN
         (
              SELECT * FROM art_test WHERE rownum <= v_rows
         )
    
         LOOP
    
              v_artnr := artnr(rec.ber, rec.wgr, rec.agr, rec.art_no);
    
         END LOOP;
    
         dbms_monitor.session_trace_disable;
    
    END single_test_simple;
    
    PROCEDURE bulk_test_simple 
    AS
    
         v_artnr VARCHAR2 (10) ;
    
         CURSOR c_art
         IS
              SELECT * FROM art_test WHERE rownum <= 2000 ;
    
    type t_art
    IS
    
         TABLE OF c_art%rowtype;
         r_art t_art;
         v_counter pls_integer DEFAULT 0;
    
    BEGIN
    
         EXECUTE IMMEDIATE 'alter session set tracefile_identifier=''bulk_simple''';
         dbms_monitor.session_trace_enable (NULL, NULL, true, true) ;
    
         IF c_art%isopen THEN
              CLOSE c_art;
         END IF;
    
         OPEN c_art;
    
         LOOP
    
              FETCH c_art BULK COLLECT INTO r_art LIMIT 100;
              EXIT WHEN r_art.count = 0;
              FOR i IN r_art.first .. r_art.last
              LOOP
              
                   v_artnr   := artnr(r_art(i).ber, r_art(i).wgr, r_art(i).agr, r_art(i).art_no);
    
              END LOOP;
         
         END LOOP;
         
         CLOSE c_art;
         
         dbms_monitor.session_trace_disable;
    
    END bulk_test_simple;
    
    
    FUNCTION artnr  ( 
                      bereich IN pls_integer,
                      wg      IN pls_integer,
                      ag      IN pls_integer,
                      art     IN pls_integer
                    )
    return varchar2
    IS
    BEGIN
      RETURN bereich||wg||ag||art;
    END artnr;
    END bulk_test;
    /
    You see, I tried with a small cheat oracle function, but without success.

    Both ended up with the following entry in the trace file:
    SELECT *
    FROM
     ART WHERE ROWNUM <= :B1 
    
    
    call     count       cpu    elapsed       disk      query    current        rows
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    Parse        1      0.00       0.00          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch       21      0.03       0.02          0         98          0        2000
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    total       23      0.03       0.02          0         98          0        2000
    Does anyone know a little trick to prevent oracle to optimize this cursor for loop? Perhaps via the compiler settings or something with the recursive function calls or anything like that.
    DML incidentally is no option, because this will lead to discussions with the wrong focus.

    Thank you very much

    Joerg

    Does anyone know a little trick to prevent oracle to optimize this cursor for loop?

    ALTER SESSION SET plsql_optimize_level = 0.
    

    Recompile, run again.

    SQL ID: 1vd852s4v1tvv
    Plan Hash: 1582900074
    SELECT *
    FROM
     ART_TEST WHERE ROWNUM <= :B1
    
    call     count       cpu    elapsed       disk      query    current        rows
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    Parse        1      0.00       0.00          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch     2001      0.01       0.01          0       2003          0        2000
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    total     2003      0.01       0.01          0       2003          0        2000
    
  • Error using BULK collect with RECORD TYPE

    Hello

    I wrote a simple procedure to declare a record type & then by a variable of type NESTED table.

    I then selects the data using COLLECT in BULK & trying to access it via a LOOP... We get an ERROR.

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

    CREATE OR REPLACE PROCEDURE sp_test_bulkcollect
    IS

    TYPE rec_type () IS RENDERING
    emp_id VARCHAR2 (20).
    level_id NUMBER
    );

    TYPE v_rec_type IS TABLE OF THE rec_type;

    BEGIN

    SELECT employe_id, level_id
    LOOSE COLLECTION v_rec_type
    OF portfolio_exec_level_mapping
    WHERE portfolio_execp_id = 2851852;

    FOR indx IN v_rec_type. FIRST... v_rec_type. LAST
    LOOP

    dbms_output.put_line ('Emp-' | v_rec_type.emp_id (indx) |) » '|| v_rec_type.level_id (indx));

    END LOOP;

    END;
    -----------------------------------------------------------------------------------------------------------------------------------

    Here is the ERROR I get...


    -Errors of compilation for the PROCEDURE DOMRATBDTESTUSER. SP_TEST_BULKCOLLECT

    Error: PLS-00321: expression "V_REC_TYPE" is not appropriate for the left side of an assignment statement
    Online: 15
    Text: IN portfolio_exec_level_mapping

    Error: PL/SQL: ORA-00904: invalid identifier
    Online: 16
    Text: WHERE portfolio_execp_id = 2851852;

    Error: PL/SQL: statement ignored
    Line: 14
    Text: COLLECT LOOSE v_rec_type

    Error: PLS-00302: component 'FIRST' must be declared
    Online: 19
    Text: LOOP

    Error: PL/SQL: statement ignored
    Online: 19
    Text: LOOP
    ------------------------------------------------------------------------------------------------

    Help PLZ.

    and with a complete code example:

    SQL> CREATE OR REPLACE PROCEDURE sp_test_bulkcollect
      2  IS
      3  TYPE rec_type IS RECORD (
      4  emp_id VARCHAR2(20),
      5  level_id NUMBER
      6  );
      7  TYPE v_rec_type IS TABLE OF rec_type;
      8  v v_rec_type;
      9  BEGIN
     10     SELECT empno, sal
     11     BULK COLLECT INTO v
     12     FROM emp
     13     WHERE empno = 7876;
     14     FOR indx IN v.FIRST..v.LAST
     15     LOOP
     16        dbms_output.put_line('Emp -- '||v(indx).emp_id||' '||v(indx).level_id);
     17     END LOOP;
     18  END;
     19  /
    
    Procedure created.
    
    SQL>
    SQL> show error
    No errors.
    SQL>
    SQL> begin
      2     sp_test_bulkcollect;
      3  end;
      4  /
    Emp -- 7876 1100
    
    PL/SQL procedure successfully completed.
    
  • bulk collect with limit

    code is: cursor here can fetch a large amount of data (22000 records). So I have to go with the limit clause. I use two foralls. This code snippet is correct with regard to the two foralls, exit and % bulk_rowcount sql statement? I have to use in production. Is there something that can break the code?

    OPEN c1;
    LOOP
    C1 FETCH BULK COLLECT WITHIN the limits of the 100 id_array;
    FORALL i IN id_array. FIRST... id_array. LAST
    Update statement;
    BECAUSE me IN id_array. FIRST... id_array. LAST
    LOOP
    v_cnt: = v_cnt + SQL % BULK_ROWCOUNT (i);
    END LOOP;
    FORALL i IN id_array. FIRST... id_array. LAST
    Insert statement;
    WHEN id_array EXIT. COUNT = 0;
    END LOOP;
    CLOSE c1;

    In addition, how context switching works when we use the llimit clause?
    without limit:
    collection is completely filled. then prepares to all the DML statements and go to sql and exeutes one by one.
    right?
    tasted clause say limit = 100
    100 indexes collection gets populated.then prepares all the DML statements for these 100 indices and go to the DTF sql and exeutes. And then back to pl/sql. fills the same 100 indices collection with 100 records and prepares the DML and goes to sql to run and returns to pl/sql and so on? Is this true?
    right?

    large volume of data (22000 records)

    This isn't a large volume of data.

    In addition, how context switching works when we use the llimit clause?

    You will find some good explanations here:

    http://www.Oracle.com/technology/tech/pl_sql/PDF/doing_sql_from_plsql.PDF

  • PLS-00201: identifier 'i' must be declared when using BULK COLLECT with FORALL to insert data in 2 tables?

    iHi.

    Declare
       cursor c_1
       is
        select col1,col2,col3,col4
        from table1
    
    
       type t_type is table of c_1%rowtype index by binary_integer;
       v_data t_type;
    BEGIN
       OPEN c_1;
       LOOP
          FETCH c_1 BULK COLLECT INTO v_data LIMIT 200;
          EXIT WHEN v_data.COUNT = 0;
          FORALL i IN v_data.FIRST .. v_data.LAST
             INSERT INTO xxc_table
               (col1,
                col3,
                col4
               )
                SELECT v_data (i).col1,
                       v_data (i).col3,
                       v_data (i).col4
                  FROM DUAL
                 WHERE NOT EXISTS
                              (SELECT 1
                                 FROM xxc_table a
                                WHERE col1=col1
                                      .....
                              );
                         --commit;
             INSERT INTO xxc_table1
               (col1,
               col2,
              col3,
              col4
               )
                SELECT v_data (i).col1,
                       v_data (i).col2,
                       v_data (i).col3,
                       'Y'
                  FROM DUAL
                 WHERE NOT EXISTS
                              (SELECT 1
                                 FROM xxc_table1 a
                                WHERE col1=col1
          .....
         );
    
    
           --exit when c_1%notfound;
       END LOOP;
       CLOSE c_1;
       commit;
    END;
    
    
    
    
    
    
    
    

    I get 40/28-PLS-00201: identifier 'I' must be declared what the problem in the above code please help me and I have lakhs of data

    Thank you

    Post edited by: Rajesh123 I changed IDX

    Post edited by: Rajesh123 changed t_type c_1 in Fetch

    But by using a SET of INSERT to insert into two tables at once in the same query would do the job without any collection of bulk of PL and avoid to query two times too.

    for example, as a single INSERT...

    SQL > create table table1 as
    2. Select 1 as col1, col2 of 1, 1 as col3, 1 as col4 Union double all the
    3 select 2,2,2,2 of all the double union
    4 Select 3,3,3,3 Union double all the
    5 Select 4,4,4,4 of all the double union
    6 select 5,5,5,5 of all the double union
    7 select 6,6,6,6 of all the double union
    8 select 7,7,7,7 of all the double union
    9 select 8,8,8,8 of all the double union
    10. Select 9,9,9,9 to the Union double all the
    11. Select double 10,10,10,10
    12.

    Table created.

    SQL > create table xxc_table like
    2. Select 1 as col1, col3 2, 3 as col4 Union double all the
    3. Select the 3, 4, 5 Union double all the
    4. Select the 5, 6, 7 double
    5.

    Table created.

    SQL > create table xxc_table1 like
    2. Select 3 as col1, col2, col3, 5 4 "n" as col4 Union double all the
    3. Select the 6, 7, 8, double "n"
    4.

    Table created.

    SQL > insert all
    2 when the xt_insert is null then
    3 in xxc_table (col1, col3, col4)
    4 values (col1, col3, col4)
    5 when the xt1_insert is null then
    6 in xxc_table1 (col1, col2, col3, col4)
    7 values (col1, col2, col3, 'Y')
    8. Select t1.col1 t1.col2, t1.col3, t1.col4
    9, xt.col1 as xt_insert
    10, xt1.col1 as xt1_insert
    11 from table1 t1
    12 left join external xxc_table xt (t1.col1 = xt.col1)
    13 left xt1 xxc_table1 outer join (t1.col1 = xt1.col1)
    14.

    15 rows created.

    SQL > select * from xxc_table by 1.
    COL1 COL3 COL4
    ---------- ---------- ----------
    1          2          3
    2          2          2
    3          4          5
    4          4          4
    5          6          7
    6          6          6
    7          7          7
    8          8          8
    9          9          9
    10-10-10

    10 selected lines.

    SQL > select * from xxc_table1 by 1.

    COL1 COL2 COL3 C
    ---------- ---------- ---------- -
    1          1          1 Y
    2          2          2 Y
    3          4          5 N
    4          4          4 Y
    5          5          5 Y
    6          7          8 N
    7          7          7 Y
    8          8          8 Y
    9          9          9 Y
    10-10-10

    10 selected lines.

    SQL >

  • Doubt on bulk collect with LIMIT

    Hello

    I have a doubt on in bulk to collect, when did Commit

    I have an example in PSOUG
    http://psoug.org/reference/array_processing.html
    CREATE TABLE servers2 AS
    SELECT *
    FROM servers
    WHERE 1=2;
    
    DECLARE
     CURSOR s_cur IS
     SELECT *
     FROM servers;
    
     TYPE fetch_array IS TABLE OF s_cur%ROWTYPE;
     s_array fetch_array;
    BEGIN
      OPEN s_cur;
      LOOP
        FETCH s_cur BULK COLLECT INTO s_array LIMIT 1000;
    
        FORALL i IN 1..s_array.COUNT
        INSERT INTO servers2 VALUES s_array(i);
    
        EXIT WHEN s_cur%NOTFOUND;
      END LOOP;
      CLOSE s_cur;
      COMMIT;
    END;
    If my table servers were 3 000 000 files, when do we commit? When I insert all records?
    could crash redo log?
    using 9.2.08

    muttleychess wrote:
    If my table servers were 3 000 000 files, when do we commit?

    Commit point has nothing to do with how many rows treat you. It's purely commercial leads. Your code implements a commercial operation, right? So if you're getting into before any trancaction (from the commercial point of view) other sessions will be already see changes that are (from a business point of view) incomplete. In addition, what happens if rest of trancaction (from the commercial point of view) goes down?

    SY.

  • move the MCs with loop for?

    I am trying to find a way to move video clips with a for loop

    I have 10 points called t1d-dt10, and I want to be able to put them all to y = 200.

    I understand that I can put i = 1; i < 11; i ++

    as

    for (i = 1; i < 11; i ++) {}

    DT i._y plus 200 ;}

    or

    for (i = 1; i < 11; i ++) {}

    String("DT"+i)._y = 200 ;}

    but the rest is a mess, and does not, work or glitches. I still have to find a loop help file for the movement of several video clips.

    If you just want to immediately change the positions of the bodies, then using a for loop works fine, you just use the notation of support [] to have the strings to be interpreted as the name of the instances...

    for (i = 1; i<>

    This ["dt" + i] ._y = 200;

    }

  • Problem with loop "for".

    Hi all

    How can I solve this problem

    Disable indexing on the right side of the loop for.

    Consider using shift registers.

  • Do nothing in the case structure with loop For

    Hello

    I am trying to extract data from my signal (0.3 0.4 0.6...). I want to extract values greater than 0.5 and put it in a table. If I use a loop For which I can determine each index of my data to be compared and it happened in the structure of the case. In the 'Real' box, I wanted the value to extract outside the loop For. And I want to "do nothing" if my value falls within the box 'False. ' However, it displays error, saying "' Tunnel: lack of assignment to the tunnel '."

    I tried to select 'Default', but it does not work since I use a Boolean comparison. I tried to use the registry to shift, but in vain too.

    Someone could guide me on this to extract only a value greater than 0.5 and index them?

    For example "0.6 0.7 0.8; 3 4 7 index.

    Satisfaction will be given.

    Here you have

  • Table row with loop for each group to set the variable.

    HI: There is probably a simple answer for this, but I don't the have not found...

    I have a single row table to move through a group to set a variable containing a sum running. I'm not display the amount in the table but when I saw the report, I see that the table is expanding (add lines) for each loop.

    The only line table has 3 columns.

    1st column
    <? for-each: AC_GROUP? >

    2nd column
    <? xdoxslt:set_variable ($_XDOCTX, 'xAmtVar', xdoxslt:get_variable($_XDOCTX,'xAmtVar') + CURRENT_AMOUNT)? >

    3rd column
    <? end foreach? >

    Can I use <? for each group? > or something else. My requirement is to set the value of the variable with the total running, but because the loop is adding lines for each value he travels (though not displayed), it's also affecting other areas of the presentation of the page.

    Hope it makes sense. Thanks in advance.

    You can do it many ways.

    No need to loop
    You can create a variable and specify the amount of the sum directly to that.

    
    

    or

    loop through, then add as you do.

    
    

    give any space or enter characters in a word between them, just put it in a single form field will be

    But as I said, I'd definitely go with the first option.

  • Manipulation of data collection with loop

    Hello

    I want to write a SQL procedure that calculates and generate revenue with the parameter array type.

    1. it has table for the type of income and the amount.
    > ('cash', '500')
    > ("Service", "100")
    > ('cash', '100')
    > ("sentence", "50")
    > ('Service', '200')
    > ("penalty, 80')

    2. I want to generate income as the sum of them.
    > cash: 600
    > Service: 300
    > sentence: 130

    3 table parameter means;
    "> create or replace the NUMBER TABLE (10.2) of TYPE"NUMBER_ARRAY"AS"

    Questions
    Q1. Can I sort and sum with table group?
    Q2. Type of income can be increased or decreased subsequently. This is why I don't want to fix it.
    How can I implement this dynamically?


    Any good idea?

    Thanks in advance
    Dan

    You are looking for something like this

    create or replace type objIncome as object(incomeType varchar2(50), income number(10,2))
    /
    create or replace type tblIncome as table of objIncome
    /
    declare
      lIncomeTbl tblIncome := tblIncome();
    begin
      lIncomeTbl.extend;
      lIncomeTbl(1) := objIncome('cash','500');
      lIncomeTbl.extend;
      lIncomeTbl(2) := objIncome('Service','100');
      lIncomeTbl.extend;
      lIncomeTbl(3) := objIncome('cash','100');
      lIncomeTbl.extend;
      lIncomeTbl(4) := objIncome('penalty','50');
      lIncomeTbl.extend;
      lIncomeTbl(5) := objIncome('Service','200');
      lIncomeTbl.extend;
      lIncomeTbl(6) := objIncome('penalty','80');
    
      for i in (select incometype, sum(income) income
                  from table(lIncomeTbl)
                 group by incometype)
      loop
        dbms_output.put_line('Income Type: ' || i.incometype ||' Income: ' || i.income);
      end loop;
    end;
    /
    
  • Try to make a variable with loop for

    Try to retrieve an instance of movieClip in my library and set it on stage and clickable menu do, (list drop-down/dropup)).
    Can someone help me with what I'm doing wrong?

    var MenuItem1:Array = new Array ("text1", "text2", "Text3", "text4");
    CreateM (MenuItem1.length);
    function CreateM(Menu1:Number):void
    {

    for (var i: Number = 0; i < MenuItem1.length; i ++)
    {

    var cela ["M1" + i]: TextField = new TextField();
    var cela ["M2" + i]: takki = new takki();
    This ["M2" + i] there = this ["M2" + i] there-(i*50) + (stage.stageHeight - this ["M2" + i] .height);
    This ["M1" + i] .text = MenuItem1 [i];
    This ["M1" + i] there = this ["M1" + i] there-(i*20) + (stage.stageHeight - this ["M1" + i] .height);

    addChild (this ["M2" + i]);
    addChild (this ["M1" + i]);

    This ["m2" + i] .addEventListener (MouseEvent.MOUSE_OVER, clicking);
    }
    }

    function clicking(event:MouseEvent):void

    {

    trace ("I am clicking on the button" & & this ["M2"]);

    }

    Try something like this:

    var MenuItem1:Array = new Array ("text1", "text2", "Text3", "text4");
    CreateM (MenuItem1.length);

    function CreateM(Menu1:Number):void
    {
    for (var i: Number = 0; i
    This ["M1" + i] = new TextField();
    This ["M2" + i] = new takki();
    This ["M2" + i] there = this ["M2" + i] there-(i*50) + (stage.stageHeight - this ["M2" + i] .height);
    This ["M1" + i] .text = MenuItem1 [i];
       
    This ["M1" + i] there = this ["M1" + i] there-(i*20) + (stage.stageHeight - this ["M1" + i] .height);
       
    addChild (this ["M2" + i]);
    addChild (this ["M1" + i]);

    This ["m2" + i] .addEventListener (MouseEvent.Click, clicking);
    }
    }

    function clicking(event:MouseEvent):void {}
    trace ("I am clicking on the button" & event.target.name);
    }

    Remember that you have to work with the positioning and the TextFields overlap takkis, that the click is possible only in a minor fraction of the takkis.

  • UNION operator with BULK COLLECT for one type of collection

    Hi all

    I created a table as given below:
    create or replace type coltest is table of number;

    Here are 3 blocks PL/SQL that populate the data in variables of the above mentioned type of table:


    BLOCK 1:

    DECLARE
    col1 coltest: = coltest (1, 2, 3, 4, 5, 11);
    col2 coltest: = coltest (6, 7, 8, 9, 10);
    COL3 coltest: = coltest();

    BEGIN

    SELECT * BULK COLLECT
    IN col1
    FROM (SELECT *)
    TABLE (CAST (coltest AS col1))
    UNION ALL
    SELECT * FROM TABLE (CAST (col2 AS coltest)));

    dbms_output.put_line ('col1');
    dbms_output.put_line ('col1.count: ' | col1.) (COUNT);

    BECAUSE me in 1... col1. COUNTY
    LOOP
    dbms_output.put_line (col1 (i));
    END LOOP;

    END;

    OUTPUT:
    col1
    col1. Count: 5
    6
    7
    8
    9
    10



    BLOCK 2:

    DECLARE
    col1 coltest: = coltest (1, 2, 3, 4, 5, 11);
    col2 coltest: = coltest (6, 7, 8, 9, 10);
    COL3 coltest: = coltest();

    BEGIN
    SELECT * BULK COLLECT
    IN col2
    FROM (SELECT *)
    TABLE (CAST (coltest AS col1))
    UNION ALL
    SELECT * FROM TABLE (CAST (col2 AS coltest)));

    dbms_output.put_line ('col2');
    dbms_output.put_line ('col2.count: ' | col2.) (COUNT);

    BECAUSE me in 1... col2. COUNTY
    LOOP
    dbms_output.put_line (col2 (i));
    END LOOP;
    END;

    OUTPUT:
    col2
    col2. Count: 6
    1
    2
    3
    4
    5
    11

    BLOCK 3:

    DECLARE
    col1 coltest: = coltest (1, 2, 3, 4, 5, 11);
    col2 coltest: = coltest (6, 7, 8, 9, 10);
    COL3 coltest: = coltest();

    BEGIN

    SELECT * BULK COLLECT
    IN col3
    FROM (SELECT *)
    TABLE (CAST (coltest AS col1))
    UNION ALL
    SELECT * FROM TABLE (CAST (col2 AS coltest)));

    dbms_output.put_line ('col3');
    dbms_output.put_line ('col3.count: ' | col3.) (COUNT);

    BECAUSE me in 1... Col3. COUNTY
    LOOP
    dbms_output.put_line (COL3 (i));
    END LOOP;
    END;


    OUTPUT:

    COL3
    Col3.Count: 11
    1
    2
    3
    4
    5
    11
    6
    7
    8
    9
    10

    Can someone explain please the output of the BLOCK 1 and 2? Why not in bulk collect in col1 and col2 11 return as County?

    If I remember correctly, the part INTO the query to initialize the collection in which it will collect the data, and you gather in the collections that you are querying, you end up deleting the data out of this collection until she is interrogated.

    Not really, wise trying to collect data in a collection that you are querying.

  • Using bulk collect into with assistance from the limit to avoid the TEMP tablespace error run out?

    Hi all

    I want to know if using bulk collect into limit will help to avoid the TEMP tablespace error run out.

    We use Oracle 11 g R1.

    I am assigned to a task of creating journal facilitated for all tables in a query of the APEX.

    I create procedures to execute some sql statements to create a DEC (Create table select), and then fires on these tables.

    We have about three tables with more than 26 million records.

    It seems very well running until we reached a table with more than 15 million record, we got an error says that Miss tablespace TEMP.

    I googled on this topic and retrieve the tips:

    Use NO LOG

    Parallel use

    BULK COLLECT INTO limited

    However, the questions for those above usually short-term memory rather than running out of TEMPORARY tablespace.

    I'm just a junior developer and does not have dealed with table more than 10 million documents at a time like this before.

    The database support is outsourced. If we try to keep it as minimal contact with the DBA as possible. My Manager asked me to find a solution without asking the administrator to extend the TEMP tablespace.

    I wrote a few BULK COLLECT INTO to insert about 300,000 like once on the development environment. It seems.

    But the code works only against a 000 4000 table of records. I am trying to add more data into the Test table, but yet again, we lack the tablespace on DEV (this time, it's a step a TEMP data)

    I'll give it a go against the table of 26 million records on the Production of this weekend. I just want to know if it is worth trying.

    Thanks for reading this.

    Ann

    I really need check that you did not have the sizes of huge line (like several K by rank), they are not too bad at all, which is good!

    A good rule of thumb to maximize the amount of limit clause, is to see how much memory you can afford to consume in the PGA (to avoid the number of calls to the extraction and forall section and therefore the context switches) and adjust the limit to be as close to that amount as possible.

    Use the routines below to check at what threshold value would be better suited for your system because it depends on your memory allocation and CPU consumption.  Flexibility, based on your limits of PGA, as lines of length vary, but this method will get a good order of magnitude.

    CREATE OR REPLACE PROCEDURE show_pga_memory (context_in IN VARCHAR2 DEFAULT NULL)

    IS

    l_memory NUMBER;

    BEGIN

    SELECT st. VALUE

    IN l_memory

    SYS.v_$ session se, SYS.v_$ sesstat st, SYS.v_$ statname nm

    WHERE se.audsid = USERENV ('SESSIONID')

    AND st.statistic # nm.statistic = #.

    AND themselves. SID = st. SID

    AND nm.NAME = 'pga session in memory. "

    Dbms_output.put_line (CASE

    WHEN context_in IS NULL

    THEN NULL

    ELSE context_in | ' - '

    END

    || 'Used in the session PGA memory ='

    || To_char (l_memory)

    );

    END show_pga_memory;

    DECLARE

    PROCEDURE fetch_all_rows (limit_in IN PLS_INTEGER)

    IS

    CURSOR source_cur

    IS

    SELECT *.

    FROM YOUR_TABLE;

    TYPE source_aat IS TABLE OF source_cur % ROWTYPE

    INDEX BY PLS_INTEGER;

    l_source source_aat;

    l_start PLS_INTEGER;

    l_end PLS_INTEGER;

    BEGIN

    DBMS_SESSION.free_unused_user_memory;

    show_pga_memory (limit_in |) "- BEFORE"); "."

    l_start: = DBMS_UTILITY.get_cpu_time;

    OPEN source_cur.

    LOOP

    EXTRACTION source_cur

    LOOSE COLLECTION l_source LIMITED limit_in;

    WHEN l_source EXIT. COUNT = 0;

    END LOOP;

    CLOSE Source_cur;

    l_end: = DBMS_UTILITY.get_cpu_time;

    Dbms_output.put_line (' elapsed time CPU for limit of ')

    || limit_in

    || ' = '

    || To_char (l_end - l_start)

    );

    show_pga_memory (limit_in |) "- AFTER");

    END fetch_all_rows;

    BEGIN

    fetch_all_rows (20000);

    fetch_all_rows (40000);

    fetch_all_rows (60000);

    fetch_all_rows (80000);

    fetch_all_rows (100000);

    fetch_all_rows (150000);

    fetch_all_rows (250000);

    -etc.

    END;

Maybe you are looking for