Bulk Collect and Millions of records.

Hey guys,.

I did experiences autour with big collect in GR 11, 2...

I have millioms of files with very large tables.

In fact, my question is this. How do you use bulk collect when you have millions of records?

Everytime I try to use it for bulk collect into, I have run out of memory.

So should I stick with the SQL engine when it comes to manipulate millions

folders? Is maninly bulk collect for insert, updates to use for applications?

Summer banging my head for awhile with it. Can a Pl/SQL pro if you please

Give me some advice on this?

In most cases SQL insert/update engine will end up more quickly then PL/SQL select + Insert/Update. Normally, you would use PL/SQL, if there is a complex logic that is based on calculations of several rows that can be easily made in SQL. If you must use BULK COLLECT many or / and wide lines, you can divide it into segments using LIMIT.

SY.

Tags: Database

Similar Questions

  • Exception handlers in bulk collect and for all operations?

    Hello world

    My version of DB is

    BANNER

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

    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi

    PL/SQL Release 10.2.0.1.0 - Production

    CORE 10.2.0.1.0 Production

    AMT for Linux: Version 10.2.0.1.0 - Production

    NLSRTL Version 10.2.0.1.0 - Production

    My question is, what are the possible exception handlers can add us in a bulk collect and for all operations?

    When we use for all, we add except exception and sql % bulk_exceptions. But apart from that what can we add to bulk collect?

    Kind regards

    BS2012.

    Save stores Exception all the exceptions that occur during in bulk in a collection of treatment and at the end of the most much treatment raises an exception. The SQL % BULK_EXCEPTIONS collection has all exceptions. It's the right way to handle the exception during treatment in bulk. And that's all you need. Don't know what else await you.

  • Bulk Collect and limit the rows

    Hello Oracles,

    I feel a strange (at least to me) behavior with lines in BULK COLLECT and LIMIT.
    For test purposes, I've written a procedure that uses a CURSOR, explicit AND implicit.
    When I use the explicit CURSOR and the LOOP, I use BULK COLLECT and LIMIT lines.
    I do not ROWNUM limit with my SELECT INTO. I know for a fact ROWNUM works very well since the last millennium.
    When I look at the number of rows returned when I put the LIMIT, I get weird number of extractions...

    I recover in a TABLE INDEX BY which is based on a TYPE of ENTRY.
    Here are a few results with different LIMIT values for a small group of key PRIMARIES.
    The figures below are the value of my_table . COUNTY

    Any idea would be apreciated.

    THX

    . .
    Actual number of CURSOR EXPLICIT 470553 PK = 17
    . LOOP IN BULK COLLECT LIMIT 78 retrieves: 17
    .
    Actual number of CURSOR EXPLICIT 100991 PK = 38
    . LOOP IN BULK COLLECT LIMIT 78 retrieves: 38
    .
    Actual number of CURSOR EXPLICIT 100981 PK = 183
    . LOOP IN BULK COLLECT LIMIT 78 retrieves: 27
    .
    Actual number of CURSOR EXPLICIT 101001 PK = 193
    . Retrieves LOOP IN BULK COLLECT LIMIT 78: 37
    .
    Actual number of CURSOR EXPLICIT 101033 PK = 593
    . Excerpt from LOOP BULK COLLECT LIMIT 78: 47

    *************************************************
    Actual number of CURSOR EXPLICIT 470553 PK = 17
    . LOOP IN BULK COLLECT LIMIT 100 retrieves: 17
    .
    Actual number of CURSOR EXPLICIT 100991 PK = 38
    . LOOP IN BULK COLLECT LIMIT 100 retrieves: 38
    .
    Actual number of CURSOR EXPLICIT 100981 PK = 183
    . LOOP IN BULK COLLECT LIMIT 100 retrieves: 83
    .
    Actual number of CURSOR EXPLICIT 101001 PK = 193
    . LOOP IN BULK COLLECT LIMIT 100 retrieves: 93
    .
    Actual number of CURSOR EXPLICIT 101033 PK = 593
    . LOOP IN BULK COLLECT LIMIT 100 retrieves: 93

    *************************************************

    Actual number of CURSOR EXPLICIT 470553 PK = 17
    . LOOP IN BULK COLLECT LIMIT 140 retrieves: 17
    .
    Actual number of CURSOR EXPLICIT 100991 PK = 38
    . LOOP IN BULK COLLECT LIMIT 140 retrieves: 38
    .
    Actual number of CURSOR EXPLICIT 100981 PK = 183
    . LOOP IN BULK COLLECT LIMIT 140 retrieves: 43
    .
    Actual number of CURSOR EXPLICIT 101001 PK = 193
    . LOOP IN BULK COLLECT LIMIT 140 retrieves: 53
    .
    Actual number of CURSOR EXPLICIT 101033 PK = 593
    . LOOP IN BULK COLLECT LIMIT 140 retrieves: 33

    *************************************************
    Actual number of CURSOR EXPLICIT 470553 PK = 17
    . LOOP IN BULK COLLECT LIMIT 183 retrieves: 17
    .
    Actual number of CURSOR EXPLICIT 100991 PK = 38
    . LOOP IN BULK COLLECT LIMIT 183 retrieves: 38
    .
    Actual number of CURSOR EXPLICIT 100981 PK = 183
    . LOOP IN BULK COLLECT LIMIT 183 retrieves: 0
    .
    Actual number of CURSOR EXPLICIT 101001 PK = 193
    . LOOP IN BULK COLLECT LIMIT 183 retrieves: 10
    .
    Actual number of CURSOR EXPLICIT 101033 PK = 593
    . LOOP IN BULK COLLECT LIMIT 183 retrieves: 44

    *************************************************

    Actual number of CURSOR EXPLICIT 470553 PK = 17
    . LOOP IN BULK COLLECT LIMIT 200 retrieves: 17
    .
    Actual number of CURSOR EXPLICIT 100991 PK = 38
    . LOOP IN BULK COLLECT LIMIT 200 retrieves: 38
    .
    Actual number of CURSOR EXPLICIT 100981 PK = 183
    . LOOP IN BULK COLLECT LIMIT 200 retrieves: 183
    .
    Actual number of CURSOR EXPLICIT 101001 PK = 193
    . LOOP IN BULK COLLECT LIMIT 200 retrieves: 193
    .
    Actual number of CURSOR EXPLICIT 101033 PK = 593
    . LOOP IN BULK COLLECT LIMIT 200 retrieves: 193

    *************************************************

    Actual number of CURSOR EXPLICIT 470553 PK = 17
    . LOOP IN BULK COLLECT LIMIT 600 retrieves: 17
    .
    Actual number of CURSOR EXPLICIT 100991 PK = 38
    . LOOP IN BULK COLLECT LIMIT 600 retrieves: 38
    .
    Actual number of CURSOR EXPLICIT 100981 PK = 183
    . LOOP IN BULK COLLECT LIMIT 600 retrieves: 183
    .
    Actual number of CURSOR EXPLICIT 101001 PK = 193
    . LOOP IN BULK COLLECT LIMIT 600 retrieves: 193
    .
    Actual number of CURSOR EXPLICIT 101033 PK = 593
    . LOOP IN BULK COLLECT LIMIT 600 retrieves: 593

    *************************************************
    Actual number of CURSOR EXPLICIT 470553 PK = 17
    . LOOP IN BULK COLLECT LIMIT 593 retrieves: 17
    .
    Actual number of CURSOR EXPLICIT 100991 PK = 38
    . LOOP IN BULK COLLECT LIMIT 593 retrieves: 38
    .
    Actual number of CURSOR EXPLICIT 100981 PK = 183
    . LOOP IN BULK COLLECT LIMIT 593 retrieves: 183
    .
    Actual number of CURSOR EXPLICIT 101001 PK = 193
    . LOOP IN BULK COLLECT LIMIT 593 retrieves: 193
    .
    Actual number of CURSOR EXPLICIT 101033 PK = 593
    . LOOP IN BULK COLLECT LIMIT 593 retrieves: 0

    PL/SQL procedure successfully completed.

    SQL > spool off

    I love a mystery, so I figured out how your code might look like:

    SQL> create table t
      2  as
      3  select case n1
      4         when 1 then 470553
      5         when 2 then 100991
      6         when 3 then 100981
      7         when 4 then 101001
      8         when 5 then 101033
      9         end pk
     10    from (select level n1 from dual connect by level <= 5)
     11       , (select level n2 from dual connect by level <= 593)
     12   where (  (n1 = 1 and n2 <= 17)
     13         or (n1 = 2 and n2 <= 38)
     14         or (n1 = 3 and n2 <= 183)
     15         or (n1 = 4 and n2 <= 193)
     16         or (n1 = 5 and n2 <= 593)
     17         )
     18  /
    
    Tabel is aangemaakt.
    
    SQL> declare
      2    type ta is table of number;
      3    a_limitsizes ta := ta(78,100,140,183,200,600,593);
      4    a_pks ta := ta(470553,100991,100981,101001,101033);
      5    a ta;
      6    l_actualcount number;
      7    cursor c(b number) is select pk from t where pk = b;
      8  begin
      9    for i in a_limitsizes.first .. a_limitsizes.last
     10    loop
     11      for j in a_pks.first .. a_pks.last
     12      loop
     13        l_actualcount := 0;
     14        open c(a_pks(j));
     15        loop
     16          fetch c bulk collect into a limit a_limitsizes(i);
     17          l_actualcount := l_actualcount + a.count;
     18          exit when a.count != a_limitsizes(i);
     19        end loop;
     20        close c;
     21        dbms_output.put_line('PK ' || a_pks(j) || ' EXPLICIT CURSOR Actual Count = ' || l_actualcount);
     22        dbms_output.put_line('. LOOP BULK COLLECT LIMIT ' || a_limitsizes(i) || ' retrieves : ' || a.count);
     23        dbms_output.new_line;
     24      end loop;
     25      dbms_output.put_line('*************************************************');
     26      dbms_output.new_line;
     27    end loop;
     28  end;
     29  /
    PK 470553 EXPLICIT CURSOR Actual Count = 17
    . LOOP BULK COLLECT LIMIT 78 retrieves : 17
    
    PK 100991 EXPLICIT CURSOR Actual Count = 38
    . LOOP BULK COLLECT LIMIT 78 retrieves : 38
    
    PK 100981 EXPLICIT CURSOR Actual Count = 183
    . LOOP BULK COLLECT LIMIT 78 retrieves : 27
    
    PK 101001 EXPLICIT CURSOR Actual Count = 193
    . LOOP BULK COLLECT LIMIT 78 retrieves : 37
    
    PK 101033 EXPLICIT CURSOR Actual Count = 593
    . LOOP BULK COLLECT LIMIT 78 retrieves : 47
    
    *************************************************
    
    PK 470553 EXPLICIT CURSOR Actual Count = 17
    . LOOP BULK COLLECT LIMIT 100 retrieves : 17
    
    PK 100991 EXPLICIT CURSOR Actual Count = 38
    . LOOP BULK COLLECT LIMIT 100 retrieves : 38
    
    PK 100981 EXPLICIT CURSOR Actual Count = 183
    . LOOP BULK COLLECT LIMIT 100 retrieves : 83
    
    PK 101001 EXPLICIT CURSOR Actual Count = 193
    . LOOP BULK COLLECT LIMIT 100 retrieves : 93
    
    PK 101033 EXPLICIT CURSOR Actual Count = 593
    . LOOP BULK COLLECT LIMIT 100 retrieves : 93
    
    *************************************************
    
    PK 470553 EXPLICIT CURSOR Actual Count = 17
    . LOOP BULK COLLECT LIMIT 140 retrieves : 17
    
    PK 100991 EXPLICIT CURSOR Actual Count = 38
    . LOOP BULK COLLECT LIMIT 140 retrieves : 38
    
    PK 100981 EXPLICIT CURSOR Actual Count = 183
    . LOOP BULK COLLECT LIMIT 140 retrieves : 43
    
    PK 101001 EXPLICIT CURSOR Actual Count = 193
    . LOOP BULK COLLECT LIMIT 140 retrieves : 53
    
    PK 101033 EXPLICIT CURSOR Actual Count = 593
    . LOOP BULK COLLECT LIMIT 140 retrieves : 33
    
    *************************************************
    
    PK 470553 EXPLICIT CURSOR Actual Count = 17
    . LOOP BULK COLLECT LIMIT 183 retrieves : 17
    
    PK 100991 EXPLICIT CURSOR Actual Count = 38
    . LOOP BULK COLLECT LIMIT 183 retrieves : 38
    
    PK 100981 EXPLICIT CURSOR Actual Count = 183
    . LOOP BULK COLLECT LIMIT 183 retrieves : 0
    
    PK 101001 EXPLICIT CURSOR Actual Count = 193
    . LOOP BULK COLLECT LIMIT 183 retrieves : 10
    
    PK 101033 EXPLICIT CURSOR Actual Count = 593
    . LOOP BULK COLLECT LIMIT 183 retrieves : 44
    
    *************************************************
    
    PK 470553 EXPLICIT CURSOR Actual Count = 17
    . LOOP BULK COLLECT LIMIT 200 retrieves : 17
    
    PK 100991 EXPLICIT CURSOR Actual Count = 38
    . LOOP BULK COLLECT LIMIT 200 retrieves : 38
    
    PK 100981 EXPLICIT CURSOR Actual Count = 183
    . LOOP BULK COLLECT LIMIT 200 retrieves : 183
    
    PK 101001 EXPLICIT CURSOR Actual Count = 193
    . LOOP BULK COLLECT LIMIT 200 retrieves : 193
    
    PK 101033 EXPLICIT CURSOR Actual Count = 593
    . LOOP BULK COLLECT LIMIT 200 retrieves : 193
    
    *************************************************
    
    PK 470553 EXPLICIT CURSOR Actual Count = 17
    . LOOP BULK COLLECT LIMIT 600 retrieves : 17
    
    PK 100991 EXPLICIT CURSOR Actual Count = 38
    . LOOP BULK COLLECT LIMIT 600 retrieves : 38
    
    PK 100981 EXPLICIT CURSOR Actual Count = 183
    . LOOP BULK COLLECT LIMIT 600 retrieves : 183
    
    PK 101001 EXPLICIT CURSOR Actual Count = 193
    . LOOP BULK COLLECT LIMIT 600 retrieves : 193
    
    PK 101033 EXPLICIT CURSOR Actual Count = 593
    . LOOP BULK COLLECT LIMIT 600 retrieves : 593
    
    *************************************************
    
    PK 470553 EXPLICIT CURSOR Actual Count = 17
    . LOOP BULK COLLECT LIMIT 593 retrieves : 17
    
    PK 100991 EXPLICIT CURSOR Actual Count = 38
    . LOOP BULK COLLECT LIMIT 593 retrieves : 38
    
    PK 100981 EXPLICIT CURSOR Actual Count = 183
    . LOOP BULK COLLECT LIMIT 593 retrieves : 183
    
    PK 101001 EXPLICIT CURSOR Actual Count = 193
    . LOOP BULK COLLECT LIMIT 593 retrieves : 193
    
    PK 101033 EXPLICIT CURSOR Actual Count = 593
    . LOOP BULK COLLECT LIMIT 593 retrieves : 0
    
    *************************************************
    
    PL/SQL-procedure is geslaagd.
    

    Observation of Randolf was right: you are simply watching the last extraction of a series of extractions, which is the modulo / rest.

    Example: If your cursor retrieves a total of 183 ranks with a maximum size of 100, then your loop steps through twice. The first single 100 lines, the second 83. You print only the last extraction and not the sum of all the extractions.

    Kind regards
    Rob.

  • Bulk collect and inserts

    Hello, I'm quite new to PLSQL and need some advice...

    I have several procedures that work well and do what I want to do.

    My question is, am I'm going in the right direction or would you all another way? If there were millions of records that would be the fastest way?

    All comments/comments would be greatly appreciated.

    Procedure 1:

    declare

    type membera is the table of the gym_members_payment_details.member_id%type;
    payment type is the gym_members_payment_details.payment_plan%type table;
    type date_payment_recieved is table of the gym_members_payment_details.date_payment_recieved%type;

    v_member membera;
    v_payment payment;
    v_date_payment_recieved date_payment_recieved;
    date of v_date_due;

    cursor c1 is select member_id, payment_plan, gym_members_payment_details date_payment_recieved;

    Start

    Open c1;

    collect the fetch c1 into bulk in v_member, v_payment, v_date_payment_recieved;

    Close c1;

    I'm in v_member.first... v_member. Last

    loop



    If v_payment (i) = "daily" then update gym_members_payment_details set date_payment_due = v_date_payment_recieved (i) where member_id = v_member (i);
    elsif v_payment (i) is "weekly" then update gym_members_payment_details set date_payment_due = v_date_payment_recieved (i) + 7 where member_id = v_member (i);.
    elsif v_payment (i) is "monthly" then update gym_members_payment_details set date_payment_due = v_date_payment_recieved (i) + 30 where member_id = v_member (i);.
    end if;


    end loop;

    end;

    Procedure 2

    declare

    Bench type is the gym_members_lifts.bench_kg%type table;
    squat type is the gym_members_lifts.squat_kg%type table;
    type of death is the gym_members_lifts.deadlift_kg%type table;
    type membera is the table of the gym_members_lifts.member_id%type;
    type bodyw is table of the gym_members_lifts.body_weight_kg%type;

    V_bench bench;
    v_squat squat;
    v_dead dead;
    v_body bodyw;
    number of v_total;
    number of v_ratio;
    v_member membera;

    cursor c1 is select bench_kg, squat_kg, deadlift_kg, member_id, gym_members_lifts body_weight_kg;


    Start

    / * bulk collect * /.

    Open c1;
    collect the fetch c1 into loose in v_bench, v_squat, v_dead, v_member, v_body;

    Close c1;

    / * Update gym_members elevators table with combined lifts and body weight to lift rates rounded to 2 places * /.

    I'm in v_member.first... v_member. Last
    loop


    v_total: = v_bench (i) + v_squat (i) + v_dead (i);
    Update gym_members_lifts set total_lift_kg = v_total where v_member (i) = member_id;
    v_ratio: = round ((v_bench (i) + v_squat (i) + v_dead (i)) / v_body (i), 2);
    Update gym_members_lifts set bodyweight_strength_ratio = v_ratio where v_member (i) = member_id;


    end loop;

    end;

    Published by: 882839 on November 29, 2011 14:25

    882839 wrote:

    My question is, am I'm heading in the right direction

    It depends on the type of film you make. Your direction may work for a movie comedy or a disaster, perhaps.

    or you would do any differently?

    Completely different.

    If there were millions of records that would be the fastest way?

    The fastest way is to do the absolute minimum of work to achieve the desired results.

    You do not have to shake the SQL data in a detour by the PL/SQL engine. Bulk processing is slow.

    While processing bulk is faster than 'normal' treatment - but for one reason only. Reduction in switching between SQL and PL/SQL engines.

    The cost of treatment in bulk increases PGA - using more private process memory (the most expensive type of memory of the server). More extraction in bulk, the PGA TOUR more is consumed. Very large bed can crash the Oracle db server to the risk of exhausting all the free server memory and give rise to serious swap space trashing.

    And that's all. Treatment in bulk does not run the SQL cursor all faster. Treatment in bulk does not reduce the IO very expensive and slow. There is no that activate more lines have to be extracted from the SQL cursor by context switch and thus reduce the change of context.

    In this regard, what is optimal? No change at all in context.

    How is this achieved? No treatment in bulk. It is obtained by eliminating the need to change entirely in context. This means no PL/SQL. This means that SQL.

    Optimize SQL. Minimize the PL/SQL.

    Do not use the PL/SQL engine to do the things that the SQL engine is perfectly capable of doing.

    Simplistic example in the sense of your first PL/SQL procedure:

    SQL> create table foo( id number, payment varchar2(1), due date );
    
    Table created.
    
    SQL>
    SQL> insert into foo select level, 'D', null from dual connect by level <= 5;
    
    5 rows created.
    
    SQL> insert into foo select level+5, 'W', null from dual connect by level <= 5;
    
    5 rows created.
    
    SQL>
    SQL> update     foo
      2  set        due = (
      3                  case
      4                          when payment = 'D' then trunc(sysdate+1)  --// daily payment's due date calc
      5                          when payment = 'W' then trunc(sysdate+7) --// weekly payment's due date calc
      6                  end
      7          );
    
    10 rows updated.
    
    SQL>
    SQL> select * from foo;
    
            ID P DUE
    ---------- - -------------------
             1 D 2011/12/01 00:00:00
             2 D 2011/12/01 00:00:00
             3 D 2011/12/01 00:00:00
             4 D 2011/12/01 00:00:00
             5 D 2011/12/01 00:00:00
             6 W 2011/12/07 00:00:00
             7 W 2011/12/07 00:00:00
             8 W 2011/12/07 00:00:00
             9 W 2011/12/07 00:00:00
            10 W 2011/12/07 00:00:00
    
    10 rows selected.
    
    SQL>
    
  • Problem with BULK collect and variable of Table type

    Hi all
    I defined a record type and then set an index - by table of this record type and in bulk has collected the data as shown in the code below. All this was done in an anonymous block.

    Then when I tried to set the record as an object type and not the above activities type, I got the below error:

    ORA-06550: line 34, column 6:
    PL/SQL: ORA-00947: not enough values
    ORA-06550: line 31, column 4:
    PL/SQL: SQL statement ignored

    Could you help me get the result of the first scenario with record type defined as an object?
    /* Formatted on 2009/08/03 17:01 (Formatter Plus v4.8.8) */
    DECLARE
       TYPE obj_attrib IS TABLE OF num_char_object_1
          INDEX BY PLS_INTEGER;
    
       obj_var   obj_attrib;
    
       TYPE num_char_record IS RECORD (
          char_attrib   VARCHAR2 (100),
          num_attrib    NUMBER
       );
    
       TYPE rec_attrib IS TABLE OF num_char_record
          INDEX BY PLS_INTEGER;
    
       rec_var   rec_attrib;
    BEGIN
       SELECT first_name,
              employee_id
       BULK COLLECT INTO rec_var
         FROM employees
        WHERE ROWNUM <= 10;
    
       FOR iloop IN rec_var.FIRST .. rec_var.LAST
       LOOP
          DBMS_OUTPUT.put_line (
             'Loop.' || iloop || rec_var (iloop).char_attrib || '###'
             || rec_var (iloop).num_attrib
          );
       END LOOP;
    
       SELECT first_name,
              employee_id
       BULK COLLECT INTO obj_var
         FROM employees
        WHERE ROWNUM <= 10;
    END;
    Here's the code for num_char_object_1
    CREATE OR REPLACE TYPE NUM_CHAR_OBJECt_1 IS OBJECT (
       char_attrib   VARCHAR2 (100),
       num_attrib    NUMBER
    );

    Welcome to the forum!

    You should be collecting objects in bulk, something like

    SELECT NUM_CHAR_OBJECt_1  (first_name,
              employee_id)
       BULK COLLECT INTO obj_var
         FROM emp
        WHERE ROWNUM <= 10;
    
  • Bulk collect and type returns nothing

    Hello

    I have the following code:
    declare
         type view_my_type is table of admuser.my_view%rowtype
         index by pls_integer;
         --x admuser.my_view%rowtype;
         my_array view_my_type;
         cursor c1 is
         select *
         from admuser.my_view;
         s long;
         i number := 1;
    begin
         s := 'crate table ';
         open c1;
         loop
              fetch c1 bulk collect into my_array limit 1;
              
         --s := s ||' decode (tf.fin_dates_id, '||my_array(i).fin_dates_id||', sum(tf.act_work_cost), 0) ';
                   s := my_array(i).fin_dates_id;
              exit when c1%notfound;
         end loop;
         close c1;
         dbms_output.put_line(s);
    exception
         when others then
         null;
    end;
    This code returns PL/SQL procedure successfully completed.
    but don't show me is not the variable "s".

    Can you help me with this?

    Thank you

    There a quite a number of things not just here.
    First of all, allow me to reproduce your situation:

    SQL> create table my_view
      2  as
      3  select 'hello' fin_dates_id from dual
      4  /
    
    Table created.
    
    SQL> declare
      2    type view_my_type is table of my_view%rowtype index by pls_integer;
      3    my_array view_my_type;
      4    cursor c1 is
      5    select *
      6    from my_view;
      7    s long;
      8    i number := 1;
      9  begin
     10    s := 'crate table ';
     11    open c1;
     12    loop
     13      fetch c1 bulk collect into my_array limit 1;
     14      s := my_array(i).fin_dates_id;
     15      exit when c1%notfound;
     16    end loop;
     17    close c1;
     18    dbms_output.put_line(s);
     19  exception
     20  when others then
     21    null;
     22  end;
     23  /
    
    PL/SQL procedure successfully completed.
    

    And I SERVEROUTPUT on. Your exception handler is notoriously wrong. It is said: If something goes wrong, we'll pretend it didn't happen. And that's exactly what happened here: something has gone wrong and you have chosen to not know about it.

    We will remove the exception handler to see what went wrong:

    SQL> declare
      2    type view_my_type is table of my_view%rowtype index by pls_integer;
      3    my_array view_my_type;
      4    cursor c1 is
      5    select *
      6    from my_view;
      7    s long;
      8    i number := 1;
      9  begin
     10    s := 'crate table ';
     11    open c1;
     12    loop
     13      fetch c1 bulk collect into my_array limit 1;
     14      s := my_array(i).fin_dates_id;
     15      exit when c1%notfound;
     16    end loop;
     17    close c1;
     18    dbms_output.put_line(s);
     19  end;
     20  /
    declare
    *
    ERROR at line 1:
    ORA-01403: no data found
    ORA-06512: at line 14
    

    A no-data-found, because you are referencing my_array (i), when I is null. Just move the OUTPUT when a line upwards as well as your code runs better:

    SQL> declare
      2    type view_my_type is table of my_view%rowtype index by pls_integer;
      3    my_array view_my_type;
      4    cursor c1 is
      5    select *
      6    from my_view;
      7    s long;
      8    i number := 1;
      9  begin
     10    s := 'crate table ';
     11    open c1;
     12    loop
     13      fetch c1 bulk collect into my_array limit 1;
     14      exit when c1%notfound;
     15      s := my_array(i).fin_dates_id;
     16    end loop;
     17    close c1;
     18    dbms_output.put_line(s);
     19  end;
     20  /
    hello
    
    PL/SQL procedure successfully completed.
    

    Then next to fix things are:
    -do not use the long data type Use a VARCHAR2 or a CLOB.
    -' Cashier' should probably be 'create '.
    -in bulk, treatment with limit 1. Now you have the worst of both sides: line by line, treatment and slightly more complex syntax
    -Variable increment I
    -Easier (and thus better) use a loop FOR

    I hope this helps.

    Kind regards
    Rob.

  • Bulk collect and cursors using rowtype

    Hello

    I'm trying just one big collect of a table and display one of the values.
    It keeps giving me the error:

    dbms_output.put_line ('f_viewed_rec: ' | f_viewed_rec.job_id (i));
    *
    ERROR on line 66:
    ORA-06550: line 66, column 53:
    PLS-00302: component 'JOB_ID' must be declared.


    ----
    cursor f_viewed IS
    Select job_id of the work;

    type f_viewed_type is table of the f_viewed % rowtype;
    f_viewed_rec f_viewed_type;

    Start

    Open f_viewed;

    LOOP

    F_viewed fetch bulk collect within the limit of 5000 f_viewed_rec;

    --------

    I'm in f_viewed_rec.first... f_viewed_rec. Last

    LOOP

    dbms_output.put_line ('f_viewed_rec: ' | f_viewed_rec.job_id (i));

    END LOOP;

    END LOOP;

    end;
    /

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

    Any ideas? Thanks much for any help.

    -Jenny

    Difficulty

    dbms_output.put_line('f_viewed_rec: '||f_viewed_rec.job_id(i));
    

    TO

    dbms_output.put_line('f_viewed_rec: '||f_viewed_rec(i).job_id);
    

    Kind regards
    Sayan M.

  • In BULK COLLECT IN the Table "Record".

    Hello

    I can't find a solution for this case. I try to extract the data in an array of different records with subtype records.

    -Table example:

    CREATE THE TABLE1 TABLE:

    ("COLUMN1" NUMBER,

    "COLUMN2" NUMBER,

    "COLUMN3" NUMBER,

    "COLUMN4" NUMBER,

    COLUMN '5' NUMBER,

    "COLUMN6" NUMBER

    );

    -Sample data:

    INSERT INTO TABLE1 (COLUMN1, COLUMN2, COLUMN3, COLUMN4, COLUMN 5, COLUMN6) VALUES ('11', '12', '13', '14', 15', 16');

    INSERT INTO TABLE1 (COLUMN1, COLUMN2, COLUMN3, COLUMN4, COLUMN 5, COLUMN6) VALUES ('21', '22', '23', '24', 25', 26');

    INSERT INTO TABLE1 (COLUMN1, COLUMN2, COLUMN3, COLUMN4, COLUMN 5, COLUMN6) VALUES ('31', '32', '33', '34', 35', 36');

    INSERT INTO TABLE1 (COLUMN1, COLUMN2, COLUMN3, COLUMN4, COLUMN 5, COLUMN6) VALUES ('41', '42', '43', '44,' 45', 46');

    INSERT INTO TABLE1 (COLUMN1, COLUMN2, COLUMN3, COLUMN4, COLUMN 5, COLUMN6) VALUES ('51', '52', '53', '54,' 55' 56');

    Here, I stated some of the columns of the table as individual records / use in the RETURN of some of the features clause.

    DECLARE

    TYPE t_col_group1 IS RECORD (col2 of TABLE1. COLUMN2% TYPE

    col3 TABLE1. COLUMN3% TYPE

    );

    TYPE t_col_group2 IS RECORD (col4 TABLE1. COLUMN2% TYPE

    col5 TABLE1. COLUMN3% TYPE

    );

    TYPE t_coll_collection IS RECORD (col1 TABLE1. % TYPE COLUMN1

    col_group1 t_col_group1

    col_group2 t_col_group2

    col6 TABLE1. % TYPE COLUMN1

    );

    TYPE t_table IS the TABLE OF t_coll_collection INDEX DIRECTORY.

    v_table t_table;

    CURSOR c_table IS

    SELECT COLUMN1, COLUMN2, COLUMN3, COLUMN4, COLUMN 5, COLUMN6

    FROM TABLE1;

    BEGIN

    OPEN c_table.

    Get the c_table COLLECT in BULK IN v_table;

    CLOSE C_table;

    END;

    I can ' manage to get the data in the table with the COLLECTION in BULK:

    Fehlerbericht:

    ORA-06550: Line 25, column 35:

    PLS-00597: expression "V_TABLE" in the list IS of the wrong type

    ORA-06550: Line 25, column 3:

    PL/SQL: SQL statement ignored

    06550 00000 - "line %s, column % s:\n%s".

    * Cause: Usually a PL/SQL compilation error.

    * Action:

    Thank you!

    André

    My environment:

    Oracle Database 11 g Release 11.2.0.3.0 - 64 bit Production
    PL/SQL Release 11.2.0.3.0 - Production
    CORE Production 11.2.0.3.0
    AMT for Linux: Version 11.2.0.3.0 - Production

    NLSRTL Version 11.2.0.3.0 - Production

    You must define the SQL type

    create or replace type t_col_group1 as an object (col2, col3 number number)
    /
    create or replace type t_col_group2 as an object (col4 number, number col5)
    /
    create or replace type t_coll_collection as an object
    (
    number of col1
    col_group1 t_col_group1
    col_group2 t_col_group2
    number col6
    )
    /
    create or replace type t_table as the t_coll_collection table
    /

    declare
    v_table t_table;

    cursor c_table
    is
    Select t_coll_collection
    (
    Column1
    t_col_group1 (column2, column3)
    t_col_group2 (column4, column5)
    column6
    )
    FROM table1;
    Start
    Open c_table;
    collect the fetch c_table in bulk in v_table;
    close c_table;
    end;
    /

  • Help BULK COLLECT

    In the emp table having 14 records when I use BULK COLLECT it inserting 12 records only
    with term his job very well, but when limit you the records to insert 12 records only
    I need 14 documents to insert into the table EMP by limiting...
    Suggest me in this
    DECLARE
      TYPE a_recs IS TABLE OF emps%ROWTYPE;
      v_recs a_recs;
    
      CURSOR c1 IS 
      SELECT * 
      FROM emp;
    BEGIN
    
      DELETE FROM emps;
      COMMIT;
    
      OPEN c1;
      LOOP
    
         FETCH c1 BULK COLLECT INTO v_recs LIMIT 3;
         EXIT WHEN c1%NOTFOUND;
    
          FORALL i IN v_recs.FIRST..v_recs.LAST
          INSERT INTO emps
            VALUES v_recs(i);
    
      END LOOP;
      CLOSE c1;
    END;
    Thank you

    assuming that it is just an exercise, change the order of FORALL and OUTPUT

    FORALL i IN v_recs.FIRST..v_recs.LAST
    INSERT INTO emps
    VALUES v_recs(i);
    EXIT WHEN c1%NOTFOUND;
    

    otherwise, just do

    insert into emps
    select *
      from emp
    

    Published by: Alex Nuijten on August 5, 2009 08:50

  • Question about BULK COLLECT

    If I have something like what follows (pseudocode)
    SELECT MYOBJECT (one, two, three)
    BULK COLLECT INTO MYTABLE
    FROM Table1
    WHERE Table1.Select = 1;
    Can I make a second BULK COLLECT and add to the existing data in the Table, or if it replaces the data?

    something like
    SELECT MYOBJECT (one, two, three)
    BULK COLLECT INTO MYTABLE
    FROM Table1
    WHERE Table1.Select = 1;
    
    SELECT MYOBJECT (one, two, three)
    BULK COLLECT INTO MYTABLE
    FROM Table1
    WHERE Table1.Select = 2;
    I know the above could be done in a single BULK COLLECT, but I am curious about the concept. I tried to have a look on the web but cannot find anything...

    Kind regards
    Toby

    the collection will be replaced by the last BULK COLLECT

  • Select Insert and bulk collect into exadata

    Hi all

    We work in Oracle Exadata. I am new to oracle exacta.  We need to insert some 7.5 million records in our table. My manager who has worked at exadata asked me to insert, select to load the data of 7.5 million records from one table to another. He asked me to forget fired fresh concepts in bulk. I read exadata prefer basic set rank of basic techniques. Is in bulk collect not a technical set base? Select Insert or in bulk which is a better technique, gather to load records from one table to the other in oracle exadata? Please advise me on this issue

    Mantra of Tom apply for Exadata and, in its follow-up here:

    Ask Tom & quot; DML only insert & #x2F; Select or bulk collect... & quot;

  • In bulk processing error in bulk to collect and more

    Hello

    I'm trying just to update my skills of collection in bulk...

    (1) as 11 g has removed restriction of the individual column of the PL/SQL associative array reference, I read somewhere we can deal with exceptions recorded in bulk rather than line-by-line processing in a loop for. can someone please guide me on this provide a link or an example for the same.


    (2) using the bulk collect is good to use implicit cursors (SELECT... BULK COLLECT INTO LIMIT...) or explicit cursor(FETCH..) is good


    3) there are various available ways to navigate the collection as the FIRST... LAST, 1.COUNT, CLUES, etc. VALUES which work fine in the coding in real-time


    All links to best practices would be very useful

    Thanks and greetings
    HESH
    --create table emp_tst as select * from emp where 1=2;
    
    --exec dbms_errlog.create_error_log('EMP_TST');
    
    --select * from emp_tst
    
    --select * from err$_emp_tst
    
    --truncate table err$_emp_tst;
    
    DECLARE
    cursor C is
    select EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO
    from emp;
    type array is table of c%rowtype;
    l_data array;
    
    dml_errors EXCEPTION;
    PRAGMA exception_init(dml_errors, -24381);
    l_errors number;
    l_errno number;
    l_msg varchar2(4000);
    l_idx number;
    begin
    open c;
    loop
    fetch c bulk collect into l_data limit 100;
    begin
    forall i in 1 .. l_data.count SAVE EXCEPTIONS
    insert into emp_tst values l_data(i);
    exception
    when DML_ERRORS then
    l_errors := sql%bulk_exceptions.count;
    for i in 1 .. l_errors
    loop
    l_errno := sql%bulk_exceptions(i).error_code;
    l_msg := sqlerrm(-l_errno);
    l_idx := sql%bulk_exceptions(i).error_index;
    insert into err$_emp_tst
    (ORA_ERR_MESG$,empno,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO)
    values
    ( 
    --l_errno,
    l_msg,
    --l_idx,
    l_data(l_idx).empno,
    l_data(l_idx).ENAME,
    l_data(l_idx).JOB,
    l_data(l_idx).MGR,
    l_data(l_idx).HIREDATE,
    l_data(l_idx).SAL,
    l_data(l_idx).COMM,
    l_data(l_idx).DEPTNO
    );
    end loop;
    end;
    exit when c%notfound;
    end loop;
    close c;
    end; 

    Hi try referring to article
    http://www.Oracle.com/technetwork/issue-archive/2012/12-Sep/o52plsql-1709862.html

  • 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 into the record type

    Sorry for the stupid question - I do something really simple wrong here, but can not understand. I want to choose a few rows from a table in a cursor, then in bulk it collect in a folder. I'll possibly extended the record to include additional fields that I will select return of functions, but I can't get this simple test case to run...

    PLS-00497 is the main error.

    Thanks in advance.
    create table test (
    id number primary key,
    val varchar2(20),
    something_else varchar2(20));
    
    insert into test (id, val,something_else) values (1,'test1','else');
    insert into test (id, val,something_else) values (2,'test2','else');
    insert into test (id, val,something_else) values (3,'test3','else');
    insert into test (id, val,something_else) values (4,'test4','else');
    
    commit;
    
    SQL> declare
      2   cursor test_cur is
      3   (select id, val
      4   from test);
      5
      6   type test_rt is record (
      7     id   test.id%type,
      8     val      test.val%type);
      9
     10   test_rec test_rt;
     11
     12  begin
     13    open test_cur;
     14    loop
     15      fetch test_cur bulk collect into test_rec limit 10;
     16       null;
     17     exit when test_rec.count = 0;
     18    end loop;
     19    close test_cur;
     20  end;
     21  /
        fetch test_cur bulk collect into test_rec limit 10;
                                         *
    ERROR at line 15:
    ORA-06550: line 15, column 38:
    PLS-00497: cannot mix between single row and multi-row (BULK) in INTO list
    ORA-06550: line 17, column 21:
    PLS-00302: component 'COUNT' must be declared
    ORA-06550: line 17, column 2:
    PL/SQL: Statement ignored

    You must declare an array based on your registration type.

    DECLARE
       CURSOR test_cur
       IS
             SELECT
                id,
                val
             FROM
                test
       ;
    type test_rt
    IS
       record
       (
          id test.id%type,
          val test.val%type);
       type test_rec_arr is table of test_rt index by pls_integer;
       test_rec test_rec_arr;
    BEGIN
       OPEN test_cur;
       LOOP
          FETCH
             test_cur bulk collect
          INTO
             test_rec limit 10;
          NULL;
          EXIT
       WHEN test_rec.count = 0;
       END LOOP;
       CLOSE test_cur;
    END;
     31  /
    
    PL/SQL procedure successfully completed.
    
    Elapsed: 00:00:00.06
    ME_XE?
    

    Notice that the difference is...

       type test_rec_arr is table of test_rt index by pls_integer;
       test_rec test_rec_arr;
    
  • Procedure failed when using bulk collect clause and works with the cursor

    Hi all

    I use "BULK collect into" clause in my procedure and it is a failure after 21 minutes and gives the error "end of file communication channel.
    After that this error comes when I tried to connect the database it gives following error.

    ORA-01034 - Oracle is not available.
    ORA - 27101-shared memory realm does not exist.
    SVR4 error: 2: no such file or directory.

    When I use the cursor instead of the COLLECTION in BULK IN the clause, it runs successfully.

    Following the code works with the slider.
    procedure work_kiosk_full (an_jobid in number, ac_sqlcode out varchar2, ac_sqlerrm out varchar2) is

    ld_curr_time Date;

    cursor cur_work_kiosk is
    Select distinct jt.jt_id AS jt_id,
    NVL ((ROUND ((jt_date_completed-jt_date_requested) * 24, 2)))
    ),
    0
    ) AS actual_hrs_to_complete,
    NVL ((ROUND ((jt_date_responded-jt_date_requested) * 24, 2)))
    ),
    0
    ) AS actual_hrs_to_respond,
    peo1.peo_name AS agent_name,
    peo1.peo_user_name AS asagent_soe_id,
    Le.lglent_desc AS ap_system,
    "" AS assign_work_request_comment,
    DECODE (jt.jt_bill_id,
    138802, 'BILLABLE CLIENT. "
    138803, "CONTRACTED"
    "138804, ' BILLABLE IN-HOUSE."
    NULL, ' '
    ) Billable.
    BL.bldg_name_cc BUILDING, bl.bldg_id_ls AS building_id,
    DECODE (bl.bldg_active_cc,
    'Y', 'ACTIVE',
    'INACTIVE '.
    ) AS building_status,
    DECODE (jt.jt_wrk_cause_id,
    141521, "STANDARD WEAR."
    141522, "NEGLIGENCE."
    141523, "ACCIDENTAL."
    141524, "MECHANICAL FAILURE."
    141525, "CONTROL."
    141526, "VANDAL."
    141527, 'STANDARD ',.
    141528, "WORK PROJECT",.
    6058229, "TEST."
    NULL, ' '
    ) AS cause_type,
    ' ' AS comments, peo3.peo_name AS completed_by,
    JT.jt_requestor_email AS contact_email,
    JT.jt_requestor_name_first
    || ' '
    || JT.jt_requestor_name_last AS contact_name,
    JT.jt_requestor_phone AS contact_phone,
    CC.cstctrcd_apcode AS corp_code,
    CC.cstctrcd_code AS cost_center,
    JT.jt_date_closed AS date_closed,
    JT.jt_date_completed AS date_completed,
    JT.jt_date_requested AS date_requested,
    JT.jt_date_responded AS date_responded,
    JT.jt_date_response_ecd AS date_response_ecd,
    JT.jt_date_scheduled AS date_scheduled,
    DECODE (jt.jt_def_id,
    139949, "WTG VENDOR RESPONSE."
    139950, "WAITING ON PARTS."
    139951, "AVAILABILITY OF THE HAND ŒUVRE."
    139952, "WORK DEFERRED-HI PRI."
    139953, "APPROVAL OF WIND TURBINES."
    139954, "FUNDING."
    139955, "ACCESS DENIED."
    139956, "WTG MATERIAL."
    NULL, ' '
    ) AS deferral_reason,
    JT.jt_description as description,
    JT.jt_date_resched_ecd IN the development of the young child,
    FMG.facility_manager AS facility_manager,
    FL.floors_text AS FLOOR, gl.genled_desc AS general_ledger,
    '' AS kiosk_date_requested,' ' AS kiosk_dispatch_confirmed.
    "" AS kiosk_dispatched,
    EQP.equip_customer_code AS linked_equipment_alias,
    EQP.equip_id AS linked_equipment_id,
    EQP.equip_text AS linked_equipment_name,
    DECODE (jt_originator_type_id,
    1000, "PROJECT MOVE REQUEST."
    138834, "CUSTOMER OPEN CORRECTION."
    138835, "OPEN REQUEST CUSTOMER."
    138836, "CORRECTIVE MAINTENANCE",.
    138837, "BOOKING CONFERENCE ROOM."
    138838, "PROJECT INITIATED REQUEST."
    138839, "PLANNED PREVENTATIVE MAINTENANCE."
    138840, "COULD START FREE APPLICATION."
    NULL, ' '
    ) AS originator_type,
    "" AS payment_terms, priority_text AS priority_code,
    swoty.sworktype_text AS problem_type,
    Prop.property_name_cc as a property,
    JT.jt_cost_quote_total AS quote_total,
    par.levels_name IN the region,
    DECODE (jt.jt_repdef_id,
    141534, 'ADJUSTED SETTING. "
    141535, "THE TRAINING OF THE END,"
    141536, "NEW REQUEST"
    141537, "NO INVESTIGATION OF REPAIR."
    141538 "REPLACED PARTS."
    141539, 'REPLACE EQUIPMEN.
    1000699, "NEW REQUEST"
    NULL, ' '
    ) AS repair_definitions,
    JT.jt_repairdesc AS MARKED_COR,
    JT.jt_requestor AS applicant, ' ' AS requestor_cost_center.
    JT.jt_requestor_email AS requestor_email,
    JT.jt_requestor_name_first AS requestor_name,
    JT.jt_requestor_phone AS requestor_phone,
    "" LIKE response_time, rm.room_name_cc ROOM,
    P1.peo_provider_code1 AS service_provider,
    P1.peo_address_1 AS service_provider_address,
    peocity.city_text service_provider_city,
    P1.peo_provider_code1 AS service_provider_code,
    peocity.city_country_name AS service_provider_country,
    peocur.currency_text AS service_provider_currency,
    P1.peo_name AS service_provider_description,
    P1.peo_dispatch_method AS serv_prov_dispatc_hmethod,
    P1.peo_rate_double AS serv_prov_double_time_rate,
    P1.peo_email AS service_provider_email,
    P1.peo_emergency_phone AS serv_prov_emergency_phone,
    P1.peo_fax AS service_provider_fax_number,
    P1.peo_home_phone AS service_provider_home_phone,
    P1.peo_rate_hourly AS service_provider_hourly_rate,
    P1.peo_title AS service_provider_job_title,
    P1.peo_method_id AS service_provider_method,
    P1.peo_cell_phone AS service_provider_mobile_phone,
    P1.peo_pager AS service_provider_pager,
    P1.peo_rate_differential AS service_provider_rates,
    P1.peo_rate_differential AS ser_prov_shift_differential,
    peocity.city_state_prov_text AS serv_prov_state_province,
    DECODE (p1.peo_active,
    'Y', 'ACTIVE',
    'INACTIVE '.
    ) AS service_provider_status,
    P1.peo_url AS serv_prov_web_site_address,
    P1.peo_phone AS service_provider_work_phone,
    P1.peo_postal_code AS serv_prov_zip_postal_code, ' ' shift, as.
    ' ' AS skill,.
    DECODE (jt.jt_bigstatus_id,
    138813, «NEWS»,
    138814 "PENDING."
    138815, 'OPEN ',.
    138816, "END."
    138817, 'CLOSED ',.
    138818, "CANCELLED."
    NULL, ' '
    ) The STATUS,
    Lev.levels_name IN the subregion, ' ' IN the trade.
    P1.peo_ls_interface_code1 AS vendor_id,
    P1.peo_fax AS vendor_purchasing_fax,
    P1.peo_vendor_site_code AS vendor_sitecode,
    JT.jt_id AS vendor_ticket, p1.peo_name AS vendor_companyname,
    JT.jt_requestor_vip AS vip, wo.wo_id AS work_order_no,
    JT.jt_id AS work_request,
    JT.jt_class_id AS work_request_class,
    woty.worktype_text AS work_type, ' ' AS wr_cost.
    JT.jt_description AS wr_description,
    "" AS wr_dispatch_method,
    DECODE (jt.jt_bigstatus_id,
    138813, «NEWS»,
    138814 "PENDING."
    138815, 'OPEN ',.
    138816, "END."
    138817, 'CLOSED ',.
    138818, "CANCELLED."
    NULL, ' '
    ) AS wr_status,
    ctrY.country_name as a country
    OF citi.jobticket jt,.
    Citi.Property prop,
    Citi.Bldg bl,
    Citi.bldg_levels bldglvl,
    civil LEVEL lev,
    civil by LEVELS.
    (SELECT crstools.stragg (peo_name) facility_manager,
    bldgcon_bldg_id
    OF citi.bldg_contacts, citi.people
    WHERE bldgcon_peo_id = peo_id
    AND IN bldgcon_contype_id (40181, 10142)
    FMG GROUP BY bldgcon_bldg_id),
    Citi.floors, fl,
    Citi.Room rm,
    Citi.general_ledger gl,
    the Citi.legal_entity
    Citi.cost_center_codes cc,
    Citi.Equipment eqp,
    Citi.workType woty,
    Citi.subworktype swoty,
    Citi.work_order wo,
    Jtwo Citi.jt_workers,
    Citi.Priority,
    Ctry Citi.Country,
    Citi.People p1,
    Citi.People peo3,
    Citi.People peo1,
    Citi.City peocity,
    Citi.Currency peocur
    WHERE jt.jt_bldg_id = bl.bldg_id
    AND bl.bldg_id = bldglvl.bldg_levels_bldg_id
    AND bldglvl.bldg_levels_levels_id = lev.levels_id
    AND lev.levels_parent = par.levels_id (+)
    AND prop.property_id = bl.bldg_property_id
    AND bl.bldg_active_ls <>' n
    AND jt.jt_floors_id = fl.floors_id (+)
    AND jt.jt_room_id = rm.room_id (+)
    AND jt.jt_bldg_id = fmg.bldgcon_bldg_id (+)
    AND jt.jt_genled_id = gl.genled_id (+)
    AND gl.genled_lglent_id = le.lglent_id (+)
    AND jt.jt_cstctrcd_id = cc.cstctrcd_id (+)
    AND jt.jt_equip_id = eqp.equip_id (+)
    AND jt.jt_id = jtwo.jtw_jt_id (+)
    AND jt.jt_worktype_id = woty.worktype_id (+)
    AND jt.jt_sworktype_id = swoty.sworktype_id (+)
    AND jt.jt_wo_id = wo.wo_id
    AND jt.jt_priority_id = priority_id (+)
    - AND jt.jt_date_requested > = ADD_MONTHS (SYSDATE,-12)
    AND jt.jt_last_update > = ADD_MONTHS (ld_curr_time-12)
    AND bl.bldg_country_id = ctry.country_id
    AND jtwo.jtw_peo_id = p1.peo_id (+)
    AND p1.peo_city_id = peocity.city_id (+)
    AND jt.jt_completed_by_peo_id = peo3.peo_id (+)
    AND p1.peo_rate_currency_id = peocur.currency_id (+)
    AND jt.jt_agent_peo_id = peo1.peo_id (+);


    BEGIN
    run immediately 'truncate table crstools.drt_bom_work_kiosk;
    Select sysdate in double ld_curr_time;
    FOR cur_rec in cur_work_kiosk LOOP
    IF MOD (cur_work_kiosk % rowcount, 10000) = 0 then
    COMMIT;
    END IF;

    INSERT INTO crstools.drt_bom_work_kiosk
    (JT_ID
    ACTUAL_HRS_TO_COMPLETE
    ACTUAL_HRS_TO_RESPOND
    AGENT_NAME
    ASAGENT_SOE_ID
    AP_SYSTEM
    ASSIGN_WORK_REQUEST_COMMENT
    BILLABLE
    BUILDING
    BUILDING_ID
    BUILDING_STATUS
    CAUSE_TYPE
    COMMENTS
    COMPLETED_BY
    CONTACT_EMAIL
    CONTACT_NAME
    CONTACT_PHONE
    CORP_CODE
    COST_CENTER
    DATE_CLOSED
    DATE_COMPLETED
    DATE_REQUESTED
    DATE_RESPONDED
    DATE_RESPONSE_ECD
    DATE_SCHEDULED
    DEFERRAL_REASON
    DESCRIPTION
    DPE
    FACILITY_MANAGER
    FLOOR
    GENERAL_LEDGER
    KIOSK_DATE_REQUESTED
    KIOSK_DISPATCH_CONFIRMED
    KIOSK_DISPATCHED
    LINKED_EQUIPMENT_ALIAS
    LINKED_EQUIPMENT_ID
    LINKED_EQUIPMENT_NAME
    ORIGINATOR_TYPE
    PAYMENT_TERMS
    PRIORITY_CODE
    PROBLEM_TYPE
    PROPERTY
    QUOTE_TOTAL
    REGION
    REPAIR_DEFINITIONS
    MARKED_COR
    APPLICANT
    REQUESTOR_COST_CENTER
    REQUESTOR_EMAIL
    REQUESTOR_NAME
    REQUESTOR_PHONE
    RESPONSE_TIME
    ROOM
    SERVICE_PROVIDER
    SERVICE_PROVIDER_ADDRESS
    SERVICE_PROVIDER_CITY
    SERVICE_PROVIDER_CODE
    SERVICE_PROVIDER_COUNTRY
    SERVICE_PROVIDER_CURRENCY
    SERVICE_PROVIDER_DESCRIPTION
    SERV_PROV_DISPATC_HMETHOD
    SERV_PROV_DOUBLE_TIME_RATE
    SERVICE_PROVIDER_EMAIL
    SERV_PROV_EMERGENCY_PHONE
    SERVICE_PROVIDER_FAX_NUMBER
    SERVICE_PROVIDER_HOME_PHONE
    SERVICE_PROVIDER_HOURLY_RATE
    SERVICE_PROVIDER_JOB_TITLE
    SERVICE_PROVIDER_METHOD
    SERVICE_PROVIDER_MOBILE_PHONE
    SERVICE_PROVIDER_PAGER
    SERVICE_PROVIDER_RATES
    SER_PROV_SHIFT_DIFFERENTIAL
    SERV_PROV_STATE_PROVINCE
    SERVICE_PROVIDER_STATUS
    SERV_PROV_WEB_SITE_ADDRESS
    SERVICE_PROVIDER_WORK_PHONE
    SERV_PROV_ZIP_POSTAL_CODE
    MAJ
    SKILLS
    STATUS
    SUBREGION
    TRADE
    VENDOR_ID
    VENDOR_PURCHASING_FAX
    VENDOR_SITECODE
    VENDOR_TICKET
    VENDOR_COMPANYNAME
    VIP
    WORK_ORDER_NO
    WORK_REQUEST
    WORK_REQUEST_CLASS
    WORK_TYPE
    WR_COST
    WR_DESCRIPTION
    WR_DISPATCH_METHOD
    WR_STATUS
    COUNTRY
    CREATE_DATE
    )
    VALUES
    (cur_rec.jt_id
    cur_rec, ACTUAL_HRS_TO_COMPLETE
    cur_rec, ACTUAL_HRS_TO_RESPOND
    cur_rec, AGENT_NAME
    cur_rec, ASAGENT_SOE_ID
    cur_rec, AP_SYSTEM
    cur_rec, ASSIGN_WORK_REQUEST_COMMENT
    BILLABLE cur_rec.
    cur_rec, BUILDING
    cur_rec, BUILDING_ID
    cur_rec, BUILDING_STATUS
    cur_rec, CAUSE_TYPE
    cur_rec.COMMENTS
    cur_rec.COMPLETED_BY
    cur_rec, CONTACT_EMAIL
    cur_rec, CONTACT_NAME
    cur_rec, CONTACT_PHONE
    cur_rec, CORP_CODE
    cur_rec, COST_CENTER
    cur_rec, DATE_CLOSED
    cur_rec, DATE_COMPLETED
    cur_rec, DATE_REQUESTED
    cur_rec, DATE_RESPONDED
    cur_rec, DATE_RESPONSE_ECD
    cur_rec, DATE_SCHEDULED
    cur_rec, DEFERRAL_REASON
    cur_rec, DESCRIPTION
    cur_rec, DEVELOPMENT OF THE YOUNG CHILD
    cur_rec, FACILITY_MANAGER
    cur_rec, FLOOR
    cur_rec, GENERAL_LEDGER
    cur_rec, KIOSK_DATE_REQUESTED
    cur_rec, KIOSK_DISPATCH_CONFIRMED
    cur_rec, KIOSK_DISPATCHED
    cur_rec, LINKED_EQUIPMENT_ALIAS
    cur_rec, LINKED_EQUIPMENT_ID
    cur_rec, LINKED_EQUIPMENT_NAME
    cur_rec, ORIGINATOR_TYPE
    cur_rec, PAYMENT_TERMS
    cur_rec, PRIORITY_CODE
    cur_rec, PROBLEM_TYPE
    cur_rec, PROPERTY
    cur_rec, QUOTE_TOTAL
    cur_rec, REGION
    cur_rec, REPAIR_DEFINITIONS
    cur_rec, MARKED_COR
    cur_rec, APPLICANT
    cur_rec, REQUESTOR_COST_CENTER
    cur_rec, REQUESTOR_EMAIL
    cur_rec, REQUESTOR_NAME
    cur_rec, REQUESTOR_PHONE
    cur_rec, RESPONSE_TIME
    cur_rec, ROOM
    cur_rec, SERVICE_PROVIDER
    cur_rec, SERVICE_PROVIDER_ADDRESS
    cur_rec, SERVICE_PROVIDER_CITY
    cur_rec, SERVICE_PROVIDER_CODE
    cur_rec, SERVICE_PROVIDER_COUNTRY
    cur_rec, SERVICE_PROVIDER_CURRENCY
    cur_rec, SERVICE_PROVIDER_DESCRIPTION
    cur_rec, SERV_PROV_DISPATC_HMETHOD
    cur_rec, SERV_PROV_DOUBLE_TIME_RATE
    cur_rec, SERVICE_PROVIDER_EMAIL
    cur_rec, SERV_PROV_EMERGENCY_PHONE
    cur_rec, SERVICE_PROVIDER_FAX_NUMBER
    cur_rec, SERVICE_PROVIDER_HOME_PHONE
    cur_rec, SERVICE_PROVIDER_HOURLY_RATE
    cur_rec, SERVICE_PROVIDER_JOB_TITLE
    cur_rec, SERVICE_PROVIDER_METHOD
    cur_rec, SERVICE_PROVIDER_MOBILE_PHONE
    cur_rec, SERVICE_PROVIDER_PAGER
    cur_rec, SERVICE_PROVIDER_RATES
    cur_rec, SER_PROV_SHIFT_DIFFERENTIAL
    cur_rec, SERV_PROV_STATE_PROVINCE
    cur_rec, SERVICE_PROVIDER_STATUS
    cur_rec, SERV_PROV_WEB_SITE_ADDRESS
    cur_rec, SERVICE_PROVIDER_WORK_PHONE
    cur_rec, SERV_PROV_ZIP_POSTAL_CODE
    cur_rec, UPDATE
    cur_rec SKILL.
    cur_rec, STATUS
    cur_rec subregion.
    cur_rec, TRADE
    cur_rec, VENDOR_ID
    cur_rec, VENDOR_PURCHASING_FAX
    cur_rec, VENDOR_SITECODE
    cur_rec, VENDOR_TICKET
    cur_rec, VENDOR_COMPANYNAME
    cur_rec, VIP
    cur_rec, WORK_ORDER_NO
    cur_rec, WORK_REQUEST
    cur_rec, WORK_REQUEST_CLASS
    cur_rec, WORK_TYPE
    cur_rec, WR_COST
    cur_rec, WR_DESCRIPTION
    cur_rec, WR_DISPATCH_METHOD
    cur_rec, WR_STATUS
    cur_rec, COUNTRY
    ld_curr_time
    );
    END LOOP;

    COMMIT;

    exception
    while others then
    Rollback;
    dbms_output.put_line('SQLCODE:'||) SQLCODE. "Error :'|| SQLERRM);

    end work_kiosk_full;

    Note: total record inserted 849000.

    The same code does not work with big collect in would adopt.

    Please help me why this is happening.


    Thanks and greetings
    Shyam ~.

    Shyam,

    I agree with Billy.

    Why are you not using an INSERT..SELECT ?
    
    Also, what are you trying to achieve by
    - incremental commits?
    - copying data from one table to another (using expensive I/O)?
    - using dynamic DML?
    
    Most of these approaches are typically wrong - and not recommended for scalable and performant Oracle applications.
    

    I could see you using a CURSOR for LOOP if you change the data inserted so that you could not encapsulate the changes in a query, but you do an insert in right in the table of your cursor. A much more effective way would be to use the following changes I made to your code sample:

    PROCEDURE WORK_KIOSK_FULL(AN_JOBID   IN NUMBER,
                              AC_SQLCODE OUT VARCHAR2,
                              AC_SQLERRM OUT VARCHAR2) IS
    BEGIN
       EXECUTE IMMEDIATE 'truncate table crstools.drt_bom_work_kiosk';
    
       /* Note:  The APPEND hint forces a Direct Path INSERT (see Link below code sample) and is combined with the NOLOGGING Hint */
       /*        To dramtically increase performance.  The Direct Path INSERT inserts records above the High-Water Mark on the table. */
    
       INSERT /*+ APPEND NOLOGGING */ INTO CRSTOOLS.DRT_BOM_WORK_KIOSK
          (JT_ID
          ,ACTUAL_HRS_TO_COMPLETE
          ,ACTUAL_HRS_TO_RESPOND
          ,AGENT_NAME
          ,ASAGENT_SOE_ID
          ,AP_SYSTEM
    --      ,ASSIGN_WORK_REQUEST_COMMENT     /* I commented out this COLUMN because it doesn't make sense to me to insert */
          ,BILLABLE                          /* a couple of space characters into a table.   If the intent is to leave the column NULL */
          ,BUILDING                          /* don't include it in your INSERT statement and it will be NULL.  If there is a valid reason */
          ,BUILDING_ID                       /* for inserting the spaces, then remove the "line comments" from the insert and select statments */
          ,BUILDING_STATUS
          ,CAUSE_TYPE
    --      ,COMMENTS
          ,COMPLETED_BY
          ,CONTACT_EMAIL
          ,CONTACT_NAME
          ,CONTACT_PHONE
          ,CORP_CODE
          ,COST_CENTER
          ,DATE_CLOSED
          ,DATE_COMPLETED
          ,DATE_REQUESTED
          ,DATE_RESPONDED
          ,DATE_RESPONSE_ECD
          ,DATE_SCHEDULED
          ,DEFERRAL_REASON
          ,DESCRIPTION
          ,ECD
          ,FACILITY_MANAGER
          ,FLOOR
          ,GENERAL_LEDGER
    --      ,KIOSK_DATE_REQUESTED
    --      ,KIOSK_DISPATCH_CONFIRMED
    --      ,KIOSK_DISPATCHED
          ,LINKED_EQUIPMENT_ALIAS
          ,LINKED_EQUIPMENT_ID
          ,LINKED_EQUIPMENT_NAME
          ,ORIGINATOR_TYPE
    --      ,PAYMENT_TERMS
          ,PRIORITY_CODE
          ,PROBLEM_TYPE
          ,PROPERTY
          ,QUOTE_TOTAL
          ,REGION
          ,REPAIR_DEFINITIONS
          ,REPAIR_DESCRIPTION
          ,REQUESTOR
    --      ,REQUESTOR_COST_CENTER
          ,REQUESTOR_EMAIL
          ,REQUESTOR_NAME
          ,REQUESTOR_PHONE
    --      ,RESPONSE_TIME
          ,ROOM
          ,SERVICE_PROVIDER
          ,SERVICE_PROVIDER_ADDRESS
          ,SERVICE_PROVIDER_CITY
          ,SERVICE_PROVIDER_CODE
          ,SERVICE_PROVIDER_COUNTRY
          ,SERVICE_PROVIDER_CURRENCY
          ,SERVICE_PROVIDER_DESCRIPTION
          ,SERV_PROV_DISPATC_HMETHOD
          ,SERV_PROV_DOUBLE_TIME_RATE
          ,SERVICE_PROVIDER_EMAIL
          ,SERV_PROV_EMERGENCY_PHONE
          ,SERVICE_PROVIDER_FAX_NUMBER
          ,SERVICE_PROVIDER_HOME_PHONE
          ,SERVICE_PROVIDER_HOURLY_RATE
          ,SERVICE_PROVIDER_JOB_TITLE
          ,SERVICE_PROVIDER_METHOD
          ,SERVICE_PROVIDER_MOBILE_PHONE
          ,SERVICE_PROVIDER_PAGER
          ,SERVICE_PROVIDER_RATES
          ,SER_PROV_SHIFT_DIFFERENTIAL
          ,SERV_PROV_STATE_PROVINCE
          ,SERVICE_PROVIDER_STATUS
          ,SERV_PROV_WEB_SITE_ADDRESS
          ,SERVICE_PROVIDER_WORK_PHONE
          ,SERV_PROV_ZIP_POSTAL_CODE
    --      ,SHIFT
    --      ,SKILL
          ,STATUS
          ,SUBREGION
    --      ,TRADE
          ,VENDOR_ID
          ,VENDOR_PURCHASING_FAX
          ,VENDOR_SITECODE
          ,VENDOR_TICKET
          ,VENDOR_COMPANYNAME
          ,VIP
          ,WORK_ORDER_NO
          ,WORK_REQUEST
          ,WORK_REQUEST_CLASS
          ,WORK_TYPE
    --      ,WR_COST
          ,WR_DESCRIPTION
    --      ,WR_DISPATCH_METHOD
          ,WR_STATUS
          ,COUNTRY
          ,CREATE_DATE
          )
       VALUES
          (SELECT DISTINCT
              JT.JT_ID AS JT_ID
             ,NVL((ROUND((JT_DATE_COMPLETED - JT_DATE_REQUESTED) * 24,2)),0) AS ACTUAL_HRS_TO_COMPLETE
             ,NVL((ROUND((JT_DATE_RESPONDED - JT_DATE_REQUESTED) * 24,2)),0) AS ACTUAL_HRS_TO_RESPOND
             ,PEO1.PEO_NAME AS AGENT_NAME
             ,PEO1.PEO_USER_NAME AS ASAGENT_SOE_ID
             ,LE.LGLENT_DESC AS AP_SYSTEM
    --         ,' ' AS ASSIGN_WORK_REQUEST_COMMENT
             ,DECODE(JT.JT_BILL_ID,138802,'CLIENT BILLABLE'
                                  ,138803,'CONTRACTED'
                                  ,138804,'INTERNAL BILLABLE',NULL,' ') AS BILLABLE
             ,BL.BLDG_NAME_CC AS BUILDING
             ,BL.BLDG_ID_LS AS BUILDING_ID
             ,DECODE(BL.BLDG_ACTIVE_CC, 'Y', 'ACTIVE', 'INACTIVE') AS BUILDING_STATUS
             ,DECODE(JT.JT_WRK_CAUSE_ID,141521,'STANDARD WEAR AND TEAR'
                                       ,141522,'NEGLIGENCE'
                                       ,141523,'ACCIDENTAL'
                                       ,141524,'MECHANICAL MALFUNCTION'
                                       ,141525,'OVERSIGHT'
                                       ,141526,'VANDAL'
                                       ,141527,'STANDARD'
                                       ,141528,'PROJECT WORK'
                                       ,6058229,'TEST',NULL,' ') AS CAUSE_TYPE
    --         ,' ' AS COMMENTS
             ,PEO3.PEO_NAME AS COMPLETED_BY
             ,JT.JT_REQUESTOR_EMAIL AS CONTACT_EMAIL
             ,JT.JT_REQUESTOR_NAME_FIRST || ' ' ||JT.JT_REQUESTOR_NAME_LAST AS CONTACT_NAME
             ,JT.JT_REQUESTOR_PHONE AS CONTACT_PHONE
             ,CC.CSTCTRCD_APCODE AS CORP_CODE
             ,CC.CSTCTRCD_CODE AS COST_CENTER
             ,JT.JT_DATE_CLOSED AS DATE_CLOSED
             ,JT.JT_DATE_COMPLETED AS DATE_COMPLETED
             ,JT.JT_DATE_REQUESTED AS DATE_REQUESTED
             ,JT.JT_DATE_RESPONDED AS DATE_RESPONDED
             ,JT.JT_DATE_RESPONSE_ECD AS DATE_RESPONSE_ECD
             ,JT.JT_DATE_SCHEDULED AS DATE_SCHEDULED
             ,DECODE(JT.JT_DEF_ID,139949,'WTG VENDOR RESPONSE'
                                 ,139950,'WAITING ON PARTS'
                                 ,139951,'LABOR AVAILABILITY'
                                 ,139952,'DEFERRED- HI PRI WORK'
                                 ,139953,'WTG APPROVAL'
                                 ,139954,'FUNDING REQUIRED'
                                 ,139955,'ACCESS DENIED'
                                 ,139956,'WTG MATERIAL',NULL,' ') AS DEFERRAL_REASON
             ,JT.JT_DESCRIPTION AS DESCRIPTION
             ,JT.JT_DATE_RESCHED_ECD AS ECD
             ,FMG.FACILITY_MANAGER AS FACILITY_MANAGER
             ,FL.FLOORS_TEXT AS FLOOR
             ,GL.GENLED_DESC AS GENERAL_LEDGER
    --         ,' ' AS KIOSK_DATE_REQUESTED
    --         ,' ' AS KIOSK_DISPATCH_CONFIRMED
    --         ,' ' AS KIOSK_DISPATCHED
             ,EQP.EQUIP_CUSTOMER_CODE AS LINKED_EQUIPMENT_ALIAS
             ,EQP.EQUIP_ID AS LINKED_EQUIPMENT_ID
             ,EQP.EQUIP_TEXT AS LINKED_EQUIPMENT_NAME
             ,DECODE(JT_ORIGINATOR_TYPE_ID,1000,'PROJECT MOVE REQUEST'
                                          ,138834,'CUSTOMER INITIATED CORRECTION'
                                          ,138835,'CUSTOMER INITIATED REQUEST'
                                          ,138836,'CORRECTIVE MAINTENANCE'
                                          ,138837,'CONFERENCE ROOM BOOKING'
                                          ,138838,'PROJECT INITIATED REQUEST'
                                          ,138839,'PLANNED PREVENTIVE MAINTENANCE'
                                          ,138840,'SELF INITATED REQUEST',NULL,' ') AS ORIGINATOR_TYPE
    --         ,' ' AS PAYMENT_TERMS
             ,PRIORITY_TEXT AS PRIORITY_CODE
             ,SWOTY.SWORKTYPE_TEXT AS PROBLEM_TYPE
             ,PROP.PROPERTY_NAME_CC AS PROPERTY
             ,JT.JT_COST_QUOTE_TOTAL AS QUOTE_TOTAL
             ,PAR.LEVELS_NAME AS REGION
             ,DECODE(JT.JT_REPDEF_ID,141534,'ADJUSTED SETTING'
                                    ,141535,'TRAINING FOR END'
                                    ,141536,'NEW REQUEST'
                                    ,141537,'NO REPAIR REQUIR'
                                    ,141538,'REPLACED PARTS'
                                    ,141539,'REPLACE EQUIPMEN'
                                    ,1000699,'NEW REQUEST',NULL,' ') AS REPAIR_DEFINITIONS
             ,JT.JT_REPAIRDESC AS REPAIR_DESCRIPTION
             ,JT.JT_REQUESTOR AS REQUESTOR
    --         ,' ' AS REQUESTOR_COST_CENTER
             ,JT.JT_REQUESTOR_EMAIL AS REQUESTOR_EMAIL
             ,JT.JT_REQUESTOR_NAME_FIRST AS REQUESTOR_NAME
             ,JT.JT_REQUESTOR_PHONE AS REQUESTOR_PHONE
    --         ,' ' AS RESPONSE_TIME
             ,RM.ROOM_NAME_CC AS ROOM
             ,P1.PEO_PROVIDER_CODE1 AS SERVICE_PROVIDER
             ,P1.PEO_ADDRESS_1 AS SERVICE_PROVIDER_ADDRESS
             ,PEOCITY.CITY_TEXT SERVICE_PROVIDER_CITY
             ,P1.PEO_PROVIDER_CODE1 AS SERVICE_PROVIDER_CODE
             ,PEOCITY.CITY_COUNTRY_NAME AS SERVICE_PROVIDER_COUNTRY
             ,PEOCUR.CURRENCY_TEXT AS SERVICE_PROVIDER_CURRENCY
             ,P1.PEO_NAME AS SERVICE_PROVIDER_DESCRIPTION
             ,P1.PEO_DISPATCH_METHOD AS SERV_PROV_DISPATC_HMETHOD
             ,P1.PEO_RATE_DOUBLE AS SERV_PROV_DOUBLE_TIME_RATE
             ,P1.PEO_EMAIL AS SERVICE_PROVIDER_EMAIL
             ,P1.PEO_EMERGENCY_PHONE AS SERV_PROV_EMERGENCY_PHONE
             ,P1.PEO_FAX AS SERVICE_PROVIDER_FAX_NUMBER
             ,P1.PEO_HOME_PHONE AS SERVICE_PROVIDER_HOME_PHONE
             ,P1.PEO_RATE_HOURLY AS SERVICE_PROVIDER_HOURLY_RATE
             ,P1.PEO_TITLE AS SERVICE_PROVIDER_JOB_TITLE
             ,P1.PEO_METHOD_ID AS SERVICE_PROVIDER_METHOD
             ,P1.PEO_CELL_PHONE AS SERVICE_PROVIDER_MOBILE_PHONE
             ,P1.PEO_PAGER AS SERVICE_PROVIDER_PAGER
             ,P1.PEO_RATE_DIFFERENTIAL AS SERVICE_PROVIDER_RATES
             ,P1.PEO_RATE_DIFFERENTIAL AS SER_PROV_SHIFT_DIFFERENTIAL
             ,PEOCITY.CITY_STATE_PROV_TEXT AS SERV_PROV_STATE_PROVINCE
             ,DECODE(P1.PEO_ACTIVE, 'Y', 'ACTIVE', 'INACTIVE') AS SERVICE_PROVIDER_STATUS
             ,P1.PEO_URL AS SERV_PROV_WEB_SITE_ADDRESS
             ,P1.PEO_PHONE AS SERVICE_PROVIDER_WORK_PHONE
             ,P1.PEO_POSTAL_CODE AS SERV_PROV_ZIP_POSTAL_CODE
    --         ,' ' AS SHIFT
    --         ,' ' AS SKILL
             ,DECODE(JT.JT_BIGSTATUS_ID,138813,'NEW'
                                       ,138814,'PENDING'
                                       ,138815,'OPEN'
                                       ,138816,'COMPLETED'
                                       ,138817,'CLOSED'
                                       ,138818,'CANCELLED',NULL,' ') AS STATUS
             ,LEV.LEVELS_NAME AS SUBREGION
    --         ,' ' AS TRADE
             ,P1.PEO_LS_INTERFACE_CODE1 AS VENDOR_ID
             ,P1.PEO_FAX AS VENDOR_PURCHASING_FAX
             ,P1.PEO_VENDOR_SITE_CODE AS VENDOR_SITECODE
             ,JT.JT_ID AS VENDOR_TICKET
             ,P1.PEO_NAME AS VENDOR_COMPANYNAME
             ,JT.JT_REQUESTOR_VIP AS VIP
             ,WO.WO_ID AS WORK_ORDER_NO
             ,JT.JT_ID AS WORK_REQUEST
             ,JT.JT_CLASS_ID AS WORK_REQUEST_CLASS
             ,WOTY.WORKTYPE_TEXT AS WORK_TYPE
    --         ,' ' AS WR_COST
             ,JT.JT_DESCRIPTION AS WR_DESCRIPTION
    --         ,' ' AS WR_DISPATCH_METHOD
             ,DECODE(JT.JT_BIGSTATUS_ID,138813,'NEW'
                                       ,138814,'PENDING'
                                       ,138815,'OPEN'
                                       ,138816,'COMPLETED'
                                       ,138817,'CLOSED'
                                       ,138818,'CANCELLED',NULL,' ') AS WR_STATUS
             ,CTRY.COUNTRY_NAME AS COUNTRY
             ,SYSDATE --LD_CURR_TIME
         FROM CITI.JOBTICKET JT,
              CITI.PROPERTY PROP,
              CITI.BLDG BL,
              CITI.BLDG_LEVELS BLDGLVL,
              CITI.LEVELS LEV,
              CITI.LEVELS PAR,
              (SELECT CRSTOOLS.STRAGG(PEO_NAME) FACILITY_MANAGER,
                      BLDGCON_BLDG_ID
                 FROM CITI.BLDG_CONTACTS, CITI.PEOPLE
                WHERE BLDGCON_PEO_ID = PEO_ID
                  AND BLDGCON_CONTYPE_ID IN (40181, 10142)
                GROUP BY BLDGCON_BLDG_ID) FMG,
              CITI.FLOORS FL,
              CITI.ROOM RM,
              CITI.GENERAL_LEDGER GL,
              CITI.LEGAL_ENTITY LE,
              CITI.COST_CENTER_CODES CC,
              CITI.EQUIPMENT EQP,
              CITI.WORKTYPE WOTY,
              CITI.SUBWORKTYPE SWOTY,
              CITI.WORK_ORDER WO,
              CITI.JT_WORKERS JTWO,
              CITI.PRIORITY,
              CITI.COUNTRY CTRY,
              CITI.PEOPLE P1,
              CITI.PEOPLE PEO3,
              CITI.PEOPLE PEO1,
              CITI.CITY PEOCITY,
              CITI.CURRENCY PEOCUR
        WHERE JT.JT_BLDG_ID = BL.BLDG_ID
          AND BL.BLDG_ID = BLDGLVL.BLDG_LEVELS_BLDG_ID
          AND BLDGLVL.BLDG_LEVELS_LEVELS_ID = LEV.LEVELS_ID
          AND LEV.LEVELS_PARENT = PAR.LEVELS_ID(+)
          AND PROP.PROPERTY_ID = BL.BLDG_PROPERTY_ID
          AND BL.BLDG_ACTIVE_LS = 'N'
          AND JT.JT_FLOORS_ID = FL.FLOORS_ID(+)
          AND JT.JT_ROOM_ID = RM.ROOM_ID(+)
          AND JT.JT_BLDG_ID = FMG.BLDGCON_BLDG_ID(+)
          AND JT.JT_GENLED_ID = GL.GENLED_ID(+)
          AND GL.GENLED_LGLENT_ID = LE.LGLENT_ID(+)
          AND JT.JT_CSTCTRCD_ID = CC.CSTCTRCD_ID(+)
          AND JT.JT_EQUIP_ID = EQP.EQUIP_ID(+)
          AND JT.JT_ID = JTWO.JTW_JT_ID(+)
          AND JT.JT_WORKTYPE_ID = WOTY.WORKTYPE_ID(+)
          AND JT.JT_SWORKTYPE_ID = SWOTY.SWORKTYPE_ID(+)
          AND JT.JT_WO_ID = WO.WO_ID
          AND JT.JT_PRIORITY_ID = PRIORITY_ID(+)
             --AND jt.jt_date_requested >= ADD_MONTHS (SYSDATE, -12)
          AND JT.JT_LAST_UPDATE >= ADD_MONTHS(LD_CURR_TIME, -12)
          AND BL.BLDG_COUNTRY_ID = CTRY.COUNTRY_ID
          AND JTWO.JTW_PEO_ID = P1.PEO_ID(+)
          AND P1.PEO_CITY_ID = PEOCITY.CITY_ID(+)
          AND JT.JT_COMPLETED_BY_PEO_ID = PEO3.PEO_ID(+)
          AND P1.PEO_RATE_CURRENCY_ID = PEOCUR.CURRENCY_ID(+)
          AND JT.JT_AGENT_PEO_ID = PEO1.PEO_ID(+)
          );
    
       COMMIT;
    
    EXCEPTION
       WHEN OTHERS THEN
          ROLLBACK;
          DBMS_OUTPUT.PUT_LINE('SQLCODE :' || SQLCODE || ' Error :' || SQLERRM);
    
    END WORK_KIOSK_FULL;
    

    Here is the link for infor the [Oracle Direct - Path INSERT | http://download.oracle.com/docs/cd/B10501_01/server.920/a96524/c21dlins.htm#10778].

    Also, if you are really wanting to use a CURSOR for LOOP COLLECTION in BULK, I suggest you read the article by Steven Feuerstein [PL/SQL practices: GEM VRAC | http://www.oracle.com/technology/oramag/oracle/08-mar/o28plsql.html].

    I hope this helps.
    Craig...

    If my response or response from another person was helpful, please mark accordingly

Maybe you are looking for

  • Is there any possibility to open one tab of private browsing without closing all normal windows navigation?

    I googled my question and found a similar question with a response, but the link to the add-on has been disabled by an administrator (someone tell me why?). I want to have one tab of private browsing open when I do my banking. I want the other normal

  • How to bypass the password or reinstall windows on Portege 2010?

    Hello I have a Portege laptop, P2010 with no floppy drive or a cd.Please can someone tell me how to reinstall windows or bypass the ctrl alt del on start up password because I can find a way to the t...

  • Windows XP for Satellite Pro M70

    Hi all!is there a link for the image of Windows XP for my laptop? I only DVD with image with it, but its disk image and I don't want to use it, because I can't divide my HARD drive, you don't want to use Norton Firewall, etc...Please, help if you can

  • HF R600. For some reason, my computer does not detect it.

    So, I don't know why, but my computer, windows 8 (I know..) does not detect my camera, the HF R600. It does not appear in the list of connected devices, the transfer utility said that it is not connected, I'm not sure what to do. Also, I felt that I

  • Display of the grey card

    HI all, Im trying to display a map in my main application window, but its only gray display. Help please! Map of MapField = new MapField();MapAction action = map.getAction ();action.setCenterAndZoom (new MapPoint(Lat,Long), zoom);Add (Map);