Subsequentes IN BULK COLLECT in the collection truncates existing lines?

T_tab_prds TYPE IS the % TYPE my_cursor TABLE;

v_tab_prds t_tab_prds;

OPEN my_cursor;
Fetch the my_cursor COLLECT in BULK IN v_tab_prds;
NARROW My_cursor

another session can change/remove lines

OPEN my_cursor;
Fetch the my_cursor COLLECT in BULK IN v_tab_prds; -V_tab_prds VA be zapped before second READING or lines will be mixed? I have to
-manually remove lines of v_tab_prds before the second EXTRACTION?
NARROW My_cursor

I answered Yes initially "later in BULK collect into collection truncate existing lines. Then I noticed "another session can change or remove rows" in your message. The collection is in the object memory with PL/SQL unit scope, it is stated in which is obviously not covered by sessions. So even if the collection belongs to the same unit of PL/SQL (package, SP, etc.) in different sessions, it's a different chunk of memory. So the final answer is:

Later in BULK COLLECT in the collection to the breast within the same instance of PL/SQL unit truncates existing lines. But obviously subsequent TO BULK COLLECT into the collection in another session won't affect collection in the first session.

SY.

Published by: Solomon Yakobson, October 13, 2009 14:20

Tags: Database

Similar Questions

  • Bulk collect treats all lines not containing the LIMIT clause.

    Hi all

    I was referring the Oracle Site for COLLECTION in BULK.

    http://www.Oracle.com/technology/oramag/Oracle/08-Mar/o28plsql.html

    In the following code, I found and I ran the same.

    I just want to know why motor Pl - SQL is not processing or recital 27 last lines when I use % NOTFOUND cursot attribute.


    PROCEDURE process_all_rows_foi_test (p_limit PLS_INTEGER DEFAULT 100)
    IS
       CURSOR c1
       IS
          SELECT *
            FROM all_objects
           WHERE ROWNUM <= 227;
    
       TYPE foi_rec IS TABLE OF c1%ROWTYPE
          INDEX BY PLS_INTEGER;
    
       v_foi_rec   foi_rec;
       v_number    NUMBER  := 1;
    BEGIN
       OPEN c1;
    
       LOOP
          FETCH c1
          BULK COLLECT INTO v_foi_rec LIMIT p_limit;
    
          EXIT WHEN v_foi_rec.COUNT = 0;--------EXIT WHEN c1%NOTFOUND;--->Here is the issue
          DBMS_OUTPUT.put_line (v_number);
          v_number := v_number + 1;
       END LOOP;
    
       CLOSE c1;
    END;
    Please guide me on this.

    Thank you
    Arun

    % NOTFOUND will have the value TRUE when it gets below the limit

    (it is documented)

    But your workaround works fine

    SQL> declare
      2     CURSOR c1
      3     IS
      4        SELECT *
      5          FROM all_objects
      6         WHERE ROWNUM <= 227;
      7
      8     TYPE foi_rec IS TABLE OF c1%ROWTYPE
      9        INDEX BY PLS_INTEGER;
     10
     11     v_foi_rec   foi_rec;
     12     v_number    NUMBER  := 1;
     13  BEGIN
     14     OPEN c1;
     15
     16     LOOP
     17        FETCH c1
     18        BULK COLLECT INTO v_foi_rec LIMIT 100; --p_limit;
     19
     20        EXIT WHEN v_foi_rec.COUNT = 0;--------EXIT WHEN c1%NOTFOUND;--->Here is the issue
     21        DBMS_OUTPUT.put_line (v_foi_rec.count);
     22        v_number := v_number + 1;
     23     END LOOP;
     24
     25     CLOSE c1;
     26  END;
     27  /
    100
    100
    27
    
    PL/SQL procedure successfully completed.
    
    SQL> 
    

    Another option would be to place the EXIT right before your END LOOP;

  • 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.

  • 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

  • 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;

  • Get help in BULK COLLECT IN the treatment

    the following gives me PLS-00302 error: component 'R_MDATA' must be declared

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

    declare

    error_1555 exception;

    pragma exception_init (error_1555,-1555);

    number num.

    -set the record

    TYPE RJ_RECORD is RECORD (r_rowr_mdata BLOB ROWID);

    -set the table based on the file type

    TYPE RJ_LIST_T IS TABLE OF RJ_RECORD

    INDEX BY PLS_INTEGER;

    -our structure will be bulk collect into

    l_List RJ_LIST_T;

    sql_str varchar2 (2000);

    cursor ovs_tab is SELECT table_name from user_tables;

    Start

    for c_rec in ovs_tab LOOP

    sql_str: = ' select rowid, m_data of ' | c_rec.table_name;

    run immediately sql_str

    COLLECTION in BULK IN l_list;

    for indx in 1.l_list. COUNTY

    LOOP

    Start

    NUM: = dbms_lob.instr (l_list. R_MDATA(indx), hextoraw ('889911')) ;  -He does not like r_mdata

    exception

    When error_1555 then

    -Insert in the values of corrupted_lob_data (l_list.rj_rowid (indx), c_rec.table_name);

    -commit;

    dbms_output.put_line (' corrupt tab = ' | c_rec.table_name);

    end;

    END LOOP;

    end loop;

    end;

    /

    change l_list.r_mdata (indx)

    TO

    .r_mdata l_list (indx)

    Each table has a column named m_data?

  • How to use Bulk collect in dynamic SQL with the example below:

    My Question is

    Using of dynamic SQL with collection in bulkif we pass the name of the table as "to the parameter' function, I want to display those

    An array of column names without vowels (replace the vowels by spaces or remove vowels and display).

    Please explain for example.

    Thank you!!

    It's just a predefined type

    SQL> desc sys.OdciVarchar2List
     sys.OdciVarchar2List VARRAY(32767) OF VARCHAR2(4000)
    

    You can just as easily declare your own collection type (and you are probably better served declaring your own type of readability if nothing else)

    SQL> ed
    Wrote file afiedt.buf
    
      1  CREATE OR REPLACE
      2     PROCEDURE TBL_COLS_NO_VOWELS(
      3                                  p_owner VARCHAR2,
      4                                  p_tbl   VARCHAR2
      5                                 )
      6  IS
      7     TYPE vc2_tbl IS TABLE OF varchar2(4000);
      8     v_col_list vc2_tbl ;
      9  BEGIN
     10      EXECUTE IMMEDIATE 'SELECT COLUMN_NAME FROM DBA_TAB_COLUMNS WHERE OWNER = :1 AND TABLE_NAME = :2 ORDER BY COLUMN_ID'
     11         BULK COLLECT
     12         INTO v_col_list
     13        USING p_owner,
     14              p_tbl;
     15      FOR v_i IN 1..v_col_list.COUNT LOOP
     16        DBMS_OUTPUT.PUT_LINE(TRANSLATE(v_col_list(v_i),'1AEIOU','1'));
     17      END LOOP;
     18*  END;
    SQL> /
    
    Procedure created.
    
    SQL> exec tbl_cols_no_vowels( 'SCOTT', 'EMP' );
    MPN
    NM
    JB
    MGR
    HRDT
    SL
    CMM
    DPTN
    
    PL/SQL procedure successfully completed.
    

    Justin

  • bulk collect into the collection of objects

    create or replace type typ_obj as an object
    (l_x number (10),)
    l_y varchar2 (10),
    LZ varchar2 (10)
    );

    Create the type typ_obj_tt is table of the typ_obj;

    / / DESC insert_table;
    c_x number (10)
    C_P number (10)

    temp2_table / / DESC
    doJir number (10)
    c_y varchar2 (10)
    c_z varchar2 (10)

    procedure prc_x (p_obj_out ON typ_obj_tt)
    is
    cursor c1
    is
    Select t1.c_x,
    T2.c_y,
    T2.c_z
    Of
    insert_table t1,
    temp2_table t2
    where
    ....
    ;
    Start
    Open c1;
    collect the fetch c1 into loose in p_obj_out;
    Close c1;

    end;

    raises the error

    can you tell
    How to enter data in this object of type of output table

    Thanks in advance... any help will be much appreciated...

    PL do not spam the forums with topics in double - bulk collect into the collection of objects

  • Using the slider for and BULK COLLECT INTO

    Hi all
    in this case we prefer to use the cursor AND the cursor with the LOOSE COLLECTION? The following contains two block this same query where used FOR the slider, the other is using COLLECT LOOSE. The task that is running better given in the existing? How do we measure performance between these two?

    I use the example of HR schema:
    declare
    l_start number;
    BEGIN
    l_start:= DBMS_UTILITY.get_time;
    dbms_lock.sleep(1);
    FOR employee IN (SELECT e.last_name, j.job_title FROM employees e,jobs j 
    where e.job_id=j.job_id and  e.job_id LIKE '%CLERK%' AND e.manager_id > 120 ORDER BY e.last_name)
    LOOP
      DBMS_OUTPUT.PUT_LINE ('Name = ' || employee.last_name || ', Job = ' || employee.job_title);
    END LOOP;
    DBMS_OUTPUT.put_line('total time: ' || to_char(DBMS_UTILITY.get_time - l_start) || ' hsecs');
    END;
    /
     
    declare
    l_start number;
    type rec_type is table of varchar2(20);
    name_rec rec_type;
    job_rec rec_type;
    begin
    l_start:= DBMS_UTILITY.get_time;
    dbms_lock.sleep(1);
    SELECT e.last_name, j.job_title bulk collect into name_rec,job_rec FROM employees e,jobs j 
    where e.job_id=j.job_id and  e.job_id LIKE '%CLERK%' AND e.manager_id > 120 ORDER BY e.last_name;
    for j in name_rec.first..name_rec.last loop
      DBMS_OUTPUT.PUT_LINE ('Name = ' || name_rec(j) || ', Job = ' || job_rec(j));
    END LOOP;
    DBMS_OUTPUT.put_line('total time: ' || to_char(DBMS_UTILITY.get_time - l_start) || ' hsecs');
    end;
    /
    In this code, I put a timestamp in each block, but they are useless, since they both launched virtually instantaneous...

    Best regards
    Val

    (1) bulk fired fresh primary use is to reduce the change of context between sql and pl sql engine.
    (2), you should always use LIMIT when it comes with bulk collect, this does not increase the load on the PGA.
    (3) and the ideal number of BOUNDARY lines is 100.

    Also if you really want to compare performance improvements between the two different approaches to sql pl try to use the package of runstats tom Kyte

    http://asktom.Oracle.com/pls/Apex/asktom.download_file?p_file=6551378329289980701

  • 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;
    
  • bulk collect line IDs

    Hello world

    I'm doing a big collect of the row ID in order to group my lines by pieces and then dealt with separately.

    My problem at present is that I can't seem to know what to put in my definition of type for the line id then it will work.

    the only way I get it to compile, I know it's wrong, and when I run it I get:

    ORA-21700: object does not exist or is marked for deletion

    I decided to ask here after that I went through this two positions but did not find my answer, or at least I think not.

    ORA-21700: object does not exist or is marked for deletion - nested table

    collect/rowid problem in bulk

    my code is something like this:

      type    t_rid_tab                               is table of rowid;
    
          with migr as (
            select rowid                        rid
                  ,ceil(rownum/i_chunk_size)   chunk_nr
            from TABLE m
          )
          select cast(collect(rid) as t_rid_tab)  rid_tab
          bulk collect
          into   l_row_id_tab
          from   migr
          group by chunk_nr
          ;
    

    to be honest the code part is not the biggest problem, eventually can be changed until it works.

    My two questions are:

    1 - Why do a compilation error data type in this code for my t_rid_tab (PLS-00531: not supported type in a type VARRAY of the TABLE: "ROWID")

    2 even just to execute the query in my sql developer does not work with something simple like: does not work, can someone just give me a first pointer?

    I am trying to run a small debug program to see what I get in my big, but I can't make it work... should be something pretty basic-no?

    I can't seem to run until I understand how can I declare my table of rowid type

    declare
        l_tab t_rid_tab;
    begin
          with migr as (
            select rowid                        rid
                  ,ceil(rownum/100)   chunk_nr
            from   TABLE m
          )
          select cast(collect(rid) as rowid)  rid_tab
          bulk collect
          into   l_tab
          from   migr
          group by chunk_nr
          ;
    
            debug(l_tab(1));
         
    end;
    /
    

    Thank you

    It is more clear what you want now and why you want it!

    create table test_cmg (column number (5));

    /

    insert into test_cmg

    Select the level

    of the double

    connect by level<>

    /

    Create the type TROWIDCharTable is table of the varchar2 (100)

    /

    declare

    type of TRec's record)

    Whole piece,

    RIDTable TROWIDCharTable

    );

    type TRecTable is table of the TRec;

    vRecTable TRecTable;

    Start

    with Rahul like)

    Select ceil(rownum/100) chunk_nr,

    Cast (cost vires (ROWIDTOCHAR (rowid)) as TROWIDCharTable) ridtable

    of test_cmg m

    ceil(rownum/100) group

    )

    Select chunk_nr, ridtable

    bulk collect into vRecTable

    of Rahul.

    -A loop around your data...

    end;

    /

  • Bulk collect

    Hello

    I have a pl/sql block, it will work, but runs for 10 hours, could help you modify using "bulk collect?

    (I've tried, but still had errors... so I want to see how other friends can modify with success).

    Thank you, happy Thanksgiving!

    -It's original screenplay:

    DECLARE

    CURSOR C_CURSOR IS SELECT * FROM MF_S224_RPT WHERE UIDY_LO IS NOT NULL AND PATN_LIST IS NOT NULL;

    V_DEF_DATA C_CURSOR % ROWTYPE;

    str_new_uidy_lo VARCHAR2 (255);

    CURSOR C_CURSOR_LN IS SELECT * FROM MF_S224_RPT_LN WHERE UIDY_LO IS NOT NULL;

    V_DEF_DATA_LN C_CURSOR_LN % ROWTYPE;

    str_new_uidy_lo_ln VARCHAR2 (255);

    BEGIN

    C_CURSOR OPEN;

    EXTRACT THE C_CURSOR IN V_DEF_DATA;

    C_CURSOR % LOOP WHILE

    str_new_uidy_lo: = (' & 6084 &'|) V_DEF_DATA. FISC_YEAR | ' &' | V_DEF_DATA. FISC_MNTH | ' &' | V_DEF_DATA. VR | ' &' | V_DEF_DATA. BENEFITS | ' &' | V_DEF_DATA. PATN_LIST | ' &' | V_DEF_DATA. (SLA);

    UPDATE T1 SET T1 MF_S224_RPT. UIDY_LO is str_new_uidy_lo WHERE T1. UIDY_LO = V_DEF_DATA. UIDY_LO;

    UPDATE T2 T2 SET MF_S224_RPT_LN. PRPT_ID_LO is str_new_uidy_lo WHERE T2. PRPT_ID_LO = V_DEF_DATA. UIDY_LO;

    UPDATE MF_S224_RPT_ACT T5 T5 SET. PRPT_ID_LO is str_new_uidy_lo WHERE T5. PRPT_ID_LO = V_DEF_DATA. UIDY_LO;

    EXTRACT THE C_CURSOR IN V_DEF_DATA;

    END LOOP;

    CLOSE C_CURSOR;

    C_CURSOR_LN OPEN;

    EXTRACT THE C_CURSOR_LN IN V_DEF_DATA_LN;

    C_CURSOR_LN % LOOP WHILE

    str_new_uidy_lo_ln: = ('& 6085' |) SUBSTR (V_DEF_DATA_LN. PRPT_ID_LO, 6). ' &' | V_DEF_DATA_LN. TSYM | ' &' | V_DEF_DATA_LN. GLAC | ' &' | V_DEF_DATA_LN. ACMP_YEAR | ' &' | V_DEF_DATA_LN. ACMP_MNTH | ' &' | V_DEF_DATA_LN. RCPT_DISB_IN | ' &' | V_DEF_DATA_LN. PATN);

    UPDATE MF_S224_RPT_LN SET T3 T3. UIDY_LO is str_new_uidy_lo_ln WHERE T3. UIDY_LO = V_DEF_DATA_LN. UIDY_LO;

    UPDATE MF_S224_RPT_ACT SET T4 T4. PRPT_LINE_ID_LO is str_new_uidy_lo_ln WHERE T4. PRPT_LINE_ID_LO = V_DEF_DATA_LN. UIDY_LO;

    EXTRACT THE C_CURSOR_LN IN V_DEF_DATA_LN;

    END LOOP;

    CLOSE C_CURSOR_LN;

    END;

    /

    This should be a lot faster:

    declare

    type of TRec's record)

    OLD_UIDY_LO MF_S224_RPT. UIDY_LO % TYPE,

    NEW_UIDY_LO MF_S224_RPT. TYPE % UIDY_LO

    );

    type TRecList is table of the TRec;

    vRecList TRecList;

    Start

    Select UIDY_LO,

    "& 6084 &' | FISC_YEAR | » &'|| FISC_MNTH | » &'|| VR | » &'|| BENEFITS | » &'|| PATN_LIST | » &'|| SLA

    bulk collect into vRecList

    of MF_S224_RPT

    where UIDY_LO is not null and

    PATN_LIST is not null;

    ForAll i in vRecList.First... vRecList.Last

    Update MF_S224_RPT T1

    the T1 value. UIDY_LO = vRecList (i). NEW_UIDY_LO

    where T1. UIDY_LO = vRecList (i). OLD_UIDY_LO;

    ForAll i in vRecList.First... vRecList.Last

    MF_S224_RPT_LN T2 update

    the value of T2. PRPT_ID_LO = vRecList (i). NEW_UIDY_LO

    where T2. PRPT_ID_LO = vRecList (i). OLD_UIDY_LO;

    ForAll i in vRecList.First... vRecList.Last

    Update MF_S224_RPT_ACT T5

    SET T5. PRPT_ID_LO = vRecList (i). NEW_UIDY_LO

    where T5. PRPT_ID_LO = vRecList (i). OLD_UIDY_LO;

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

    Select UIDY_LO,

    ("& 6085' | ') SUBSTR (PRPT_ID_LO, 6). » &'|| TSYM | » &'|| GLAC | » &'|| ACMP_YEAR | » &'|| ACMP_MNTH | » &'|| RCPT_DISB_IN | » &'|| PATN)

    bulk collect into vRecList

    of MF_S224_RPT_LN

    where UIDY_LO is not null;

    ForAll i in vRecList.First... vRecList.Last

    MF_S224_RPT_LN T3 update

    Set the T3. UIDY_LO = vRecList (i). NEW_UIDY_LO

    where T3. UIDY_LO = vRecList (i). OLD_UIDY_LO;

    ForAll i in vRecList.First... vRecList.Last

    Update MF_S224_RPT_ACT T4

    Set the T4. PRPT_LINE_ID_LO = vRecList (i). NEW_UIDY_LO

    where T4. PRPT_LINE_ID_LO = vRecList (i). OLD_UIDY_LO;

    end;

    /

  • Bulk collect using some different column insert a table

    Hi all

    I gave an example of emp table in my original 100 million table record are I need to change group (IE deptno) 10 to 20 copy the same records

    about these codes, I get exception

    ORA-06550: line 11, column 53:

    PLS-00386: concordance that is 'EMP_TAB' between FETCH cursor and IN variables of type

    can help me please for these

    declare

    type row_tab is table emp % rowtype

    INDEX BY PLS_INTEGER;

    emp_tab row_tab;

    cursor cur_emp is select ENAME, 20 DEPTNO, HIREDATE, emp COMM EMPNO;

    Start

    Open cur_emp;

    loop

    Cur_emp fetch bulk collect in the limit emp_tab 2000;

    ForAll i in 1.emp_tab. COUNTY

    Insert / * + APPEND * / into emp (EMPNO, ENAME, DEPTNO, HIREDATE, COMM)

    values (emp_tab (i). EMPNO, emp_tab (i). Ename, emp_tab (i). DEPTNO, emp_tab (i). HIREDATE, emp_tab (i). COMM.) ;

    When the output cur_emp % notfound;

    END LOOP;

    close cur_emp;

    end;

    /

    Thank you

    VSM

    I use the user define the type of record to over come error

    declare

    type emp_rt is record (empno, ename emp.ename%type,deptno NUMBER (2) emp.empno%type, hiredate emp.hiredate%type,comm emp.comm%type);

    TYPE row_type IS the emp_rt INDEX TABLE OF pls_integer;

    emp_tab row_type;

    cursor cur_emp is select empno, ename, 20 deptno, hiredate, comm from emp where deptno = 10;

    Start

    Open cur_emp;

    loop

    Cur_emp fetch bulk collect in the emp_tab limit 2;

    ForAll i in 1.emp_tab. COUNTY

    Insert / * + APPEND * / into EMP (EMPNO, ENAME, DEPTNO, HIREDATE, COMM)

    values (emp_tab (i). EMPNO, emp_tab (i). ENAME, emp_tab (i). DEPTNO, emp_tab (i). HIREDATE, emp_tab (i). COMM.)

    ;

    When the output cur_emp % notfound;

    END LOOP;

    close cur_emp;

    end;

    /

    records are successful inserted, I do not know is not the right approach for 100 million documents?

    Thank you

    VM

  • Get 'not enough values error' in bulk collect

    I want to insert all the rows in the employees table in the tmp table which has the structure.

    Purpose: Try just feature fired block to create a return to the top of a table.

    Problem: My code is to not "enough of values" error please report if mistaken.

    structure of the employees table:

    SQL > desc employee;

    Name                                      Null?    Type

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

    EMPLOYEE_ID NOT NULL NUMBER (6)

    FIRST NAME VARCHAR2 (20)

    LAST_NAME NOT NULL VARCHAR2 (25)

    EMAIL NOT NULL VARCHAR2 (25)

    PHONE_NUMBER VARCHAR2 (20)

    HIRE_DATE NOT NULL DATE

    JOB_ID NOT NULL VARCHAR2 (10)

    SALARY NUMBER (8.2)

    COMMISSION_PCT NUMBER (2.2)

    MANAGER_ID NUMBER (6)

    DEPARTMENT_ID NUMBER 4

    tmp table structure:

    SQL > tmp desc;

    Name                                      Null?    Type

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

    EMPLOYE_ID NUMBER (6)

    FIRST NAME VARCHAR2 (20)

    LAST_NAME NOT NULL VARCHAR2 (25)

    EMAIL NOT NULL VARCHAR2 (25)

    PHONE_NUMBER VARCHAR2 (20)

    HIRE_DATE NOT NULL DATE

    JOB_ID NOT NULL VARCHAR2 (10)

    SALARY NUMBER (8.2)

    COMMISSION_PCT NUMBER (2.2)

    MANAGER_ID NUMBER (6)

    DEPARTMENT_ID NUMBER 4

    SQL > select * from tmp;

    no selected line

    Code:

    declare

    type rec is the employee table % rowtype

    index by pls_integer;

    a rec;

    Start

    Select * bulk collect in a

    employees;

    ForAll i in a.first... a.Last

    Insert into tmp values (a (i));

    end;

    /

    Result:

    SQL > declare

    2

    3 type rec is the employee table % rowtype

    4 index of pls_integer;

    5 a rec;

    6

    7. start

    8 remove tmp;

    9 select * bulk collect in a

    10 employees;

    11 ForAll i in a.first... a.Last

    12 insert into tmp values (a (i));

    13 end;

    14.

    Insert into tmp values (a (i));

    *

    ERROR on line 12:

    ORA-06550: line 12, column 13:

    PL/SQL: ORA-00947: not enough values

    ORA-06550: line 12, column 1:

    PL/SQL: SQL statement ignored

    Remove parentheses

    insert into tmp values a(i);
    

    or call the individual columns

    insert into tmp( employee_id, first_name, ... )
     values( a(i).employee_id, a(i).first_name, ... );
    

    Justin

  • change a pl/sql block using "bulk collect.

    Hello

    I have a pl/sql block, short it slows...

    DECLARE

    CURSOR CURUPDATE1 IS

    SELECT MF_TJ. UID_LO

    OF MF_TJ

    WHERE MF_TJ. DTYP (SELECT CD

    OF MF_DOC_TYPE

    WHERE MF_DOC_TYPE. DTYP_CAT = 'xx')

    AND MF_TJ. LINE_TYP IS SET TO NULL;

    BEGIN

    FOR T IN CURUPDATE1

    LOOP

    UPDATE MF_TJ

    THE MF_TJ VALUE. LINE_TYP = "NR."

    WHERE MF_TJ. UID_LO = T.UID_LO;

    UPDATE MF_AJ

    THE MF_AJ VALUE. LINE_TYP = "NR."

    WHERE MF_AJ. TJ_UID_LO = T.UID_LO;

    END LOOP;

    END;

    /

    now I change to use bulk collect, but I split it into two pl/sql blocks (each for an update)

    DECLARE
    CURSOR CURUPDATE1 IS
    SELECT MF_TJ. UID_LO
    OF MF_TJ
    WHERE MF_TJ. DTYP (SELECT CD
    OF MF_DOC_TYPE
    WHERE MF_DOC_TYPE. DTYP_CAT = 'xx')
    AND MF_TJ. LINE_TYP IS SET TO NULL;
    TYPE of recs_type IS the TABLE OF CURUPDATE1% ROWTYPE directory INDEX;
    REB recs_type;
    BEGIN
    CURUPDATE1 OPEN;
    Go SEARCH the CURUPDATE1 COLLECT in BULK IN REB 8000 limit;
    CLOSE CURUPDATE1;
    FORALL i IN 1.recs. COUNTY
    UPDATE MF_TJ
    THE MF_TJ VALUE. LINE_TYP = "NR."
    WHERE MF_TJ. UID_LO = (i) recs. UID_LO;-

    END;
    /


    DECLARE
    CURSOR CURUPDATE1 IS
    SELECT MF_TJ. UID_LO
    OF MF_TJ
    WHERE MF_TJ. DTYP (SELECT CD
    OF MF_DOC_TYPE
    WHERE MF_DOC_TYPE. DTYP_CAT = 'xx')
    AND MF_TJ. LINE_TYP IS SET TO NULL;
    TYPE of recs_type IS the TABLE OF CURUPDATE1% ROWTYPE directory INDEX;
    REB recs_type;
    BEGIN
    CURUPDATE1 OPEN;
    Go SEARCH the CURUPDATE1 COLLECT in BULK IN REB 8000 limit;
    CLOSE CURUPDATE1;
    FORALL i IN 1.recs. COUNTY
    UPDATE MF_AJ
    THE MF_AJ VALUE. LINE_TYP = "NR."
    WHERE MF_AJ. TJ_UID_LO = (i) recs. UID_LO;-
    END;
    /

    Is there a way I can just use pl/sql block using bulk collect?

    Thank you very much

    Hi 5181139

    As Paulzip and Jarkko Turpeinen have pointed out, you could do it using only SQL...

    This is a course using COLLECT in BULK:

    DECLARE
       blimit CONSTANT PLS_INTEGER := 500;
       CURSOR curupdate1 IS
          SELECT MF_TJ.UID_LO
          FROM   MF_TJ
          WHERE  MF_TJ.DTYP IN (SELECT CD
                                FROM MF_DOC_TYPE
                                WHERE MF_DOC_TYPE.DTYP_CAT = 'xx')
          AND MF_TJ.LINE_TYP IS NULL;
       TYPE c_arr IS TABLE OF curupdate1%ROWTYPE;
       c_rows c_arr;
    BEGIN
       OPEN curupdate1;
       LOOP
          FETCH curupdate1 BULK COLLECT INTO c_rows LIMIT blimit;
          FORALL i IN c_rows.FIRST..c_rows.LAST
             UPDATE MF_TJ
             SET    MF_TJ.LINE_TYP = 'NR'
             WHERE  MF_TJ.UID_LO = c_rows(i).uid_lo;
    
          FORALL i IN c_rows.FIRST..c_rows.LAST
             UPDATE MF_AJ
             SET    MF_AJ.LINE_TYP = 'NR'
             WHERE MF_AJ.TJ_UID_LO = c_rows(i).uid_lo;
          EXIT WHEN c_rows.COUNT < blimit;
       END LOOP;
       CLOSE curupdate1;
    END;
    

    See you soon,.

    Gas

Maybe you are looking for