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.

Tags: Database

Similar Questions

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

    iHi.

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

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

    Thank you

    Post edited by: Rajesh123 I changed IDX

    Post edited by: Rajesh123 changed t_type c_1 in Fetch

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

    for example, as a single INSERT...

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

    Table created.

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

    Table created.

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

    Table created.

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

    15 rows created.

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

    10 selected lines.

    SQL > select * from xxc_table1 by 1.

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

    10 selected lines.

    SQL >

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

  • 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

  • XMLTYPE with record type

    Hi friends,

    Is it possible to use XMLTYPE with record types?

    For example, in the following code I expect output voltage

    < TY_EMP > < > 1001 EMPNO < / EMPNO > < ADAMS ENAME > < / ENAME > < SAL > 5000 < / SAL > < TASK MANAGER > < / JOB > < / TY_EMP >

    The code is...

    DECLARE

    Ty_emp RECORD TYPE IS

    (

    EmpNo INTEGER

    , ename VARCHAR2 (100)

    NUMBER of sal

    , VARCHAR2 (100) employment

    );

    r_emp ty_emp;

    BEGIN

    r_emp.EmpNo: = 1001;

    r_emp. Ename: = "Adams";

    r_emp. SAL: = 5000;

    r_emp.job: = "MANAGER";

    -This line gives the error.

    dbms_output.put_line (XmlType (r_emp). GETSTRINGVAL()); -Here, I don't want to talk about all the fields in the record. I just need to specify the name of the record.

    END;

    p.s. to use object types to generate XML data...

    SQL > ed
    A written file afiedt.buf

    1 TYPE to CREATE or REPLACE ty_emp () AS OBJECT
    2 empno INTEGER
    3, ename VARCHAR2 (100)
    4, NUMBER of sal
    5, job VARCHAR2 (100)
    6*   );
    SQL > /.

    Type of creation.

    SQL > ed
    A written file afiedt.buf

    1 DECLARE
    2 r_emp ty_emp: = new ty_emp (null, null, null, null);
    3 BEGIN
    4 r_emp.empno: = 1001;
    r_emp.ename 5: = "Adams";
    6 r_emp.sal: = 5000;
    7 r_emp.job: = "MANAGER";
    8 dbms_output.put_line (XMLTYPE (r_emp) .getstringval ());
    9 * END;
    SQL > /.
    1001 Adams 5000 MANAGER

    PL/SQL procedure successfully completed.

    SQL >

  • 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

  • In BULK COLLECT with loop for?

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

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

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

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

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

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

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

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

  • Dynamic SQL with in bulk in the record type

    Oracle 10.2 g

    I received this Tom

    [http://asktom.oracle.com/pls/apex/f?p=100:11:0:NO:]

    I'm able to do this without dynamic SQL, but my requirement is to do it in dynamic SQL
     create table t1 ( x int, y int );
    
     insert into t1 select rownum, rownum+1 from all_users where rownum <= 5;
    
     create table t2 ( x int, y int, z int );
    
     declare
                type array is table of t1%rowtype;
                l_data array;
        begin
                select * bulk collect into l_data from t1;
      
                forall i in 1 .. l_data.count
                
                       execute immediate 'insert into (select x, y from t2) values :x' using l_data(i);
        end;
     
    Error at line 1
    ORA-06550: line 9, column 90:
    PLS-00457: expressions have to be of SQL types
    ORA-06550: line 9, column 20:
    PL/SQL: Statement ignored
    There is a work around in 11g, but can we do something in 10g?



    Thank you
    HESH.

    HESH wrote:

    but following does not.

    declare
    type array is table of t1%rowtype;
    l_data array;
    begin
    select * bulk collect into l_data from t1;
    
    forall i in 1 .. l_data.count
    
    execute immediate 'insert into (select x, y from t2) values :x' using l_data(i);
    end;
    

    I want just a dynamic SQL code for the insert with FORALL statement would adopt as well as collections.

    Doesn't make much sense.

    Extract you the data from the SQL engine in the table of the record type. If the output data that cursor SQL must be read in the SQL engine and copied into the memory of PL/SQL engine.

    Then, you send that VERY SAME DATA back to the SQL engine to be used by a SQL insert cursor.

    Where is the logic behind the extraction of data from SQL in a PL/SQL table structure and then push this same structure table on the SQL engine database? What is the purpose to send data on a detour of underperforming and non-scalale through the PL/SQL engine?

    You have any justification (technical or functional wise) to back up this absurd approach?

    Why this can be achieved using a single SQL cursor that does both the choice (extraction) and (in bulk) insertion - using the plain old INSERT... SELECT structure?

    And if the insert is variable, then what? Create a dynamic INSERT... SELECT cursor and execute it (using bind values). This simple... Right?

  • Error when using bulk collect

    Hello
    I tried with the following code,
    DECLARE
       TYPE EmpRec IS RECORD (last_name   EMP.ename%TYPE, 
                              salary      emp.sal%TYPE);
       emp_info EmpRec;
       TYPE empnest IS TABLE OF EMP.empno%TYPE;
       empnestvar empnest; 
    BEGIN
      empnestvar := empnest(7566,7788);
       FOR i in empnestvar.first..empnestvar.last LOOP
       UPDATE emp SET sal = sal * 1.1 WHERE empno = empnestvar(i)
          RETURNING   ename, sal BULK COLLECT INTO  emp_info;
       DBMS_OUTPUT.PUT_LINE('Just gave a raise to ' || emp_info.last_name ||
          ', who now makes ' || emp_info.salary);
       ROLLBACK;
       END LOOP;
    END;
    get the following err
          RETURNING   ename, sal BULK COLLECT INTO  emp_info;
                         *
    ERROR at line 11:
    ORA-03113: end-of-file on communication channel
    Could you please advice me in this

    Thank you

    Why he does ' t work with

    COLLECTION in BULK IN the variable of type record. >
    This is how it is designed and defined! In fact, to put it very simply, BULK COLLECT means collectors several at a go (forgive me if my English is not the best), the record type variable can contain both.
    A vary another important thing that I missed before, avoid using COMMIT or ROLLBACK inside the loop. You can search for AskTom for more explanations.

    Published by: mohamed on April 8, 2011 18:19

  • 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

  • Error creating service with record type as a return type

    Hi, I tried the following code to get the nth highest sal using the service and the record type.
    CREATE OR REPLACE PACKAGE pack_rec_cur AS
    TYPE rec_type IS RECORD (
     name EMP.ename%TYPE,
     sal EMP.sal%TYPE);
      END;
    The lot above is created
    CREATE OR REPLACE 
      FUNCTION fun_rec_cur(n INT) RETURN pack_rec_cur.rec_type AS
       rec pack_rec_cur.rec_type;
        CURSOR cur_rec IS
          SELECT ename,sal
            FROM emp
             WHERE sal is not null 
              ORDER BY DESC;
    BEGIN
     OPEN cur_rec;
      FOR i IN 1..n LOOP
       FETCH cur_rec into rec;
       EXIT WHEN cur_rec%NOTFOUND;
      END LOOP;
     CLOSE cur_rec;
     RETURN rec;
    END;   
    The above function is errors
    LINE/COL ERROR
    -------- ---------------------------------------
    4/7      PL/SQL: SQL Statement ignored
    7/16     PL/SQL: ORA-00936: missing expression
    SQL> 
    Could you please correct me where I am wrong

    Thank you.

    By clauase missing column name in the order. Is it ename desc?

    CREATE OR REPLACE
      FUNCTION fun_rec_cur(n INT) RETURN pack_rec_cur.rec_type AS
       rec pack_rec_cur.rec_type;
        CURSOR cur_rec IS
          SELECT ename,sal
            FROM emp
             WHERE sal is not null
              ORDER BY ENAME DESC; ---added ename
    BEGIN
     OPEN cur_rec;
      FOR i IN 1..n LOOP
       FETCH cur_rec into rec;
       EXIT WHEN cur_rec%NOTFOUND;
      END LOOP;
     CLOSE cur_rec;
     RETURN rec;
    END;   
    
    ------------
    -OUTPUT
    -----------
    
    SQL> SET SERVEROUT ON
    SQL>
    SQL> DECLARE
      2     rec            pack_rec_cur.rec_type;
      3  BEGIN
      4     rec         := fun_rec_cur (6); --you get the 6th record in order of ename desc
      5     DBMS_OUTPUT.put_line ('ename::' || rec.NAME || '  sal ::' || rec.sal);
      6  END;
      7  /
    ename::MARTIN  sal ::1250
    
    PL/SQL procedure successfully completed.
    
    SQL> 
    
  • UNION operator with BULK COLLECT for one type of collection

    Hi all

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

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


    BLOCK 1:

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

    BEGIN

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

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

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

    END;

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



    BLOCK 2:

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

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

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

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

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

    BLOCK 3:

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

    BEGIN

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

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

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


    OUTPUT:

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

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

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

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

  • Doubt on bulk collect with LIMIT

    Hello

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

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

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

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

    SY.

  • make exception when using BUlk collect

    Hi all

    version of DB 10 g

    I've written a procedure as below
    create or replace procedure test_proc2 is
    
    type v_emp_rec is record 
    (empno number,
    ename varchar2 (200));
    
    type v_emp_tab is table of v_emp_rec index by binary_integer;
    
    v_tab v_emp_tab;
    
    begin
    
    select empno,ename
    into v_tab(0)
    from emp
    where empno = 7369;
    
    dbms_output.put_line (v_tab(0).ename);
    
    exception 
    when no_data_found then
    dbms_output.put_line ('I am in no data found exception');
    end;
    now, I tried to perform the procedure below
    begin
    test_proc2;
    end;
    the foregoing is works well, but I want to use the functionality of collection in bulk so I use as below
    create or replace procedure test_proc2 is
    
    type v_emp_rec is record 
    (empno number,
    ename varchar2 (200));
    
    type v_emp_tab is table of v_emp_rec index by binary_integer;
    
    v_tab v_emp_tab;
    
    begin
    
    select empno,ename bulk collect
    into v_tab
    from emp
    where empno = 7369;
    
    dbms_output.put_line (v_tab(0).ename);
    
    exception 
    when no_data_found then
    dbms_output.put_line ('I am in no data found exception');
    end;
    the foregoing gives me exception, please someone can explain why it is not in the exception block.

    Thanks in advance.

    The obvious answer is because an exception no_data_found is raised.
    The question is there.

    It's either select it because there is no data where empno = 7369.

    Or is the .ename of v_tab (0), because there is no element 0. Automatic collection of indexing starts at 1.

    for example

    SQL>  declare
      2    type t1 is table of pls_integer index by pls_integer;
      3    v1 t1;
      4   begin
      5    v1(1) := 1;
      6    dbms_output.put_line(v1(0));
      7   end;
      8  /
     declare
    *
    ERROR at line 1:
    ORA-01403: no data found
    ORA-06512: at line 6
    
    SQL> 
    

    If you catch the exceptions and do not spread them properly, then hide you all information kind of useful as a line number, etc..

  • Bulk collect with sequence Nextval

    Hello


    Oracle Database 10 g Enterprise Edition Release 10.2.0.4.0 - 64 bit


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

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


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

    Hello

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

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

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

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

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

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

    Don't forget to declare v_prop_id as a NUMBER.

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

Maybe you are looking for

  • Restore sound whoosh for mail sent to El Capitan?

    My wife has just upgraded its Macbook Pro to Snow Leopard at El Capitan. Among the countless little things that are different is that he is no longer a his "whoosh" when outgoing mail is sent in the Mail application. She really liked this sound and l

  • fixing the iPhone 6

    I want to know how much apple is responsible for setting the motherboard when the guarantee is made? If just died during my presentation done nothing for her. No water damage or anything.

  • How can I find the IP address of a device connected to the switch GS724Tv4?

    I have a Netgear GS724Tv4 switch and I need to know the IP address of a device in the g19 port. Is possible due to the switch to see? Thank you in advance. Antonio

  • Unstable network

    I do my version of FW R6300v2 V1.0.3.30 daily unstabilty experience. My devices seems to be connected, but nothing happens when I try to open Web sites, and when I try to open NETGEARGenie on my MacBook pro, is not able to find the router. Wireless n

  • What is net framework client profile 4?

    I need net framework 4 client profile I downloaded myself I think ws suppose it is. I have windows xp 32-bit, what is it year I delete it. Thank you