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 >

Tags: Database

Similar Questions

  • PLS-00201: identifier 'NVL2' must be declared.

    I came across a scenario where I saw that NVL2 is a PL/SQL function, but when I tried to use this function directly with plsql variable it gives me error. Although it is find a job within SQL.

    Here is the example I'm writing his strange behavior I see.

    I'm under banner PL/SQL Release 11.2.0.4.0 - Production

    SQL> --See when we use NVL2 within SQL it works fine
    SQL> select nvl2('IamNotNull', 'IamForNotNull', 'IamForNull') for_not_null
      2            ,nvl2(null, 'IamForNotNull', 'IamForNull') for_null
      3  from dual;
    
    
    FOR_NOT_NULL  FOR_NULL
    ------------- ----------
    IamForNotNull IamForNull
    
    
    SQL> --Problem occurs when we assign the resultant directly into variable in anonymous block
    SQL> declare
      2      for_not_null varchar2(200);
      3  begin
      4      for_not_null :=NVL2('IamNotNull', 'IamForNotNull', 'IamForNull');
      5  end;
      6  /
        for_not_null :=NVL2('IamNotNull', 'IamForNotNull', 'IamForNull');
                       *
    ERROR at line 4:
    ORA-06550: line 4, column 20:
    PLS-00201: identifier 'NVL2' must be declared
    ORA-06550: line 4, column 5:
    PL/SQL: Statement ignored
    
    
    
    
    SQL>
    

    Spear says:

    But I had look at Oracle self-documenting and it was not clear that NVL2 is SQL fucntion.

    Weird, because I just searched documentation, and the first that says NVL2 in the context of the PL/SQL language was all NVL2 hits were either programming language SQL or OLAP expression reference: http://docs.oracle.com/cd/E11882_01/appdev.112/e25519/fundamentals.htm#LNPLS00212

    which clearly states that the NVL2 is not available in PL/SQL.

  • Bogged down with PLS-00201: identifier 'P_ERR_MESSAGE1' must be declared

    I'm trying to capture an error message in the exception block, and then move it to the calling procedure. I'm getting bogged down with an error "PLS-00201: identifier 'P_ERR_MESSAGE1' must be declared '. How can I fix this or how I can pass the error message in the main proceedings.

    The situation is the following:

    -Local variable

    CRLF VARCHAR2 (2) CONSTANT: = CHR (13) | CHR (10);

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

    -FORWARD DECLARATIONS

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

    PROCEDURE p_sendmail (p_sender_email IN VARCHAR2,

    P_FROM IN VARCHAR2,

    p_to IN VARCHAR2,

    msg_subject IN VARCHAR2 DEFAULT NULL,

    p_msg_body IN LONG DEFAULT NULL,

    p_err_message1 OUT VARCHAR2);

    PROCEDURE p_sendmail (p_sender_email IN VARCHAR2,

    P_FROM IN VARCHAR2,

    p_to IN VARCHAR2,

    msg_subject IN VARCHAR2 DEFAULT NULL,

    p_msg_body IN LONG DEFAULT NULL,

    p_err_message1 OUT VARCHAR2) is

    LONG v_to_list;

    LONG v_cc_list;

    LONG v_bcc_list;

    T_DATE VARCHAR2 (255) DEFAULT TO_CHAR(SYSDATE, 'DD MON YYYY HH24:MI:SS PM');

    g_mail_conn UTL_SMTP. CONNECTION;

    SMTP_HOST CONSTANT VARCHAR2 (256): = ' smtp - abc.defg.ca';

    SMTP_PORT CONSTANT PLS_INTEGER: = 25;

    BEGIN

    g_mail_conn: = UTL_SMTP. OPEN_CONNECTION (SMTP_HOST, SMTP_PORT);

    UTL_SMTP. HELO (g_mail_conn, SMTP_HOST);

    UTL_SMTP.mail (g_mail_conn, p_sender_email);

    UTL_SMTP. RCPT (g_mail_conn, p_to);

    UTL_SMTP.open_data (g_mail_conn);

    UTL_SMTP.write_data (g_mail_conn, "|) CRLF);

    UTL_SMTP.write_data (g_mail_conn, p_msg_body);

    UTL_SMTP.close_data (g_mail_conn);

    UTL_SMTP. Quit (g_mail_conn);

    EXCEPTION

    WHEN utl_smtp.transient_error THEN

    RAISE_APPLICATION_ERROR (SQLCODE, SQLERRM);

    -DBMS_OUTPUT.put_line ('TransientError: Invalid Operation have service may not be available.');

    WHEN utl_smtp.permanent_error THEN

    RAISE_APPLICATION_ERROR (SQLCODE, SQLERRM);

    -DBMS_OUTPUT.put_line ('Permanent Error: The email id entered is either invalid or recepients mail box is full.');

    -p_errmessage: = SQLERRM;

    WHILE others THEN

    RAISE_APPLICATION_ERROR (SQLCODE, SQLERRM);

    -DBMS_OUTPUT.put_line ('Unable to send year email.');

    -p_errmessage: = SQLERRM;

    IF SQLERRM IS NOT NULL THEN

    p_err_message1: = SQLERRM;

    ON THE OTHER

    p_err_message1: = NULL;

    END IF;

    END p_sendmail;

    -Call the procedure below:

    p_sendmail (p_sender_email = > ' [email protected]'-, send an E-mail to the donor )

    p_from = > ' ADS < [email protected] > ',

    p_to = > v_store_email_address,

    p_msg_subject = > 'anonymous user ',.

    p_msg_body = > 'thank you ' |

    CRLF.

    "Email confirms that we have received your promise |

    CRLF.

    CRLF.

    ' Name:         ' || v_full_name |

    CRLF.

    ' Temporary ID: ' | v_azbwccp_id |

    CRLF.

    "Reference number: ' |" MTID |

    CRLF.

    "Amount: ' | '. TO_NUMBER (campaign_desg_amt1) |

    CRLF.

    "Campaign: ' | '. campaign |

    CRLF.

    ' Description: ' | '. adbdesg_rec.adbdesg_name |

    CRLF.

    ' Type: ' | atvpldg_rec.atvpldg_desc |

    CRLF.

    ' Duration: ' | '. atvpdur_rec.atvpdur_desc |

    CRLF.

    "Frequency: ' | '. atvfreq_rec.atvfreq_desc |

    CRLF.

    "Start date: ' | '. bill_date2 |

    CRLF.

    CRLF.

    'Your commitment is processed.' |

    CRLF.

    "At the same time, if you want to change this transaction, please contact us.

    CRLF.

    CRLF.

    "Thank you for your support." |

    CRLF.

    CRLF.

    CRLF.

    CRLF.

    ' * This is an automated message system. Please, do not respond to this email. *** ',

    p_err_message1);

    Now when I compile it, I am getting bogged down with an error message called: PLS-00201: identifier 'P_ERR_MESSAGE1' must be declared

    Where do I feel bad? When I google, talk, or the variable is not set (which is not the case) or on the privileges (which is not the case that I compiled the same procedure with fewer parameters the week last in my schema). Any idea?

    I have attached a screenshot as well. Thanks in advance.


    Yes, I was not able to copy and paste the package specifications and the whole body, because its too too big. Hope you understand.

    ScreenHunter_22 Dec. 02 10.49.jpg

    The problem is that you had declared him an OUT parameter p_err_message1. This setting is valid only inside the procedure. However, you tried to use it outdoors (during the call to the procedure). Declare and use a different variable to solve the problem.

    ...

    p_sendmail (p_sender_email => ' [email protected]'-, send an E-mail to the donor)

    ...

    CRLF.

    ' * This is an automated message system. Please, do not respond to this email. *** ',

    ( p_err_message1) ;

    To identify the problem in a quick way and constitent, generally it allows to watch the line numbers. Or use sql developer. There, you can jump directly to the error line.

  • PLS-00201: identifier 'TABLETYPE_VARCHAR2' must be declared.

    Hi all, when I copy a procedure from oracle, and then the paste into the TimesTen to re-create the procedure, I get the following exception:
    PLS-00201: identifier 'TABLETYPE_VARCHAR2' must be declared.
    If the 'TABLETYPE_VARCHAR2' type is available in oracle not in TimesTen.
    Y at - it approach to solving this problem or links to the list of incompatibilities between oracle and TimesTen on PL/SQL?


    Thank you

    Gena, it seems that the package in timesten is a substitute for custom in oracle, right types?

    TimesTen does not support object types, but we can use types in packages, it's sort of a "Workaround", I think.
    Basically, the packets do not replace custom types (there are two different objects PLSQL with different purpose), but in this case we can do.

    Best regards
    Gena

  • PLS-00201: identifier 'DBMS_FGA' must be declared.

    When I run:
    EXEC dbms_fga.add_policy (object_schema = > 'LG_SYSTEM_BOTSWANA', object_name = > policy_name, 'TB_BW_PROD_MSTR' = > 'FGA_EMP', audit_column = > NULL, audit_condition = > 'SYS_CONTEXT ("USERENV", "DB_USER") = "lg_system_botswana" ', statement_types = > 'SELECT');

    I get:
    ORA-06550: line 1, column 7:
    PLS-00201: identifier 'DBMS_FGA' must be declared.
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    06550 00000 - "line %s, column % s:\n%s".

    I guess that the privleges lack to you on the dbms_fga package. Coordinate with your dba and application privileges execute on the packaging.

  • PLS-00201: identifier 'SP_INSERT_FS_DUMP' must be declared.

    Gurus,

    I'm having a problem in a package that I have. I created this package, but when I run it I get this error

    java.sql.BatchUpdateException: ORA-06550: line 1, column 7:
    PLS-00201: identifier 'SP_INSERT_FS_DUMP' must be declared.
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored

    I use oracle 10.2.0.3. I gave subsidies to run and debug functional ID.

    The body code is too big to be pasted here. I guess this isn't the error code the compilation went well.

    Any help will be appreciated.

    CREATE OR REPLACE PACKAGE SDP
    AS
    PROCEDURE SP_INSERT_FS_DUMP (FS_DELTA in NUMBER, INTERMEDIATE_ID number, SDA in VARCHAR2, LOG_ID in NUMBER);
    END SDP;
    /

    PROCEDURE SP_INSERT_FS_DUMP
    (
    FS_DELTA number,
    INTERMEDIATE_ID number,
    SDA in VARCHAR2,
    LOG_ID NUMBER
    )
    AS
    SDAMINUS40 EXPOSURE_GMR_FS. Type of SDG_MINUS_40%;
    SDAMINUS20 EXPOSURE_GMR_FS. Type of SDG_MINUS_20%;
    SDAMINUS10 EXPOSURE_GMR_FS. Type of SDG_MINUS_10%;
    SDAMINUS5 EXPOSURE_GMR_FS. Type of SDG_MINUS_5%;
    SDA0 EXPOSURE_GMR_FS. Type of SDG_0%;
    SDAPLUS1 EXPOSURE_GMR_FS. Type of SDG_PLUS_1%;
    SDAPLUS5 EXPOSURE_GMR_FS. Type of SDG_PLUS_5%;
    SDAPLUS10 EXPOSURE_GMR_FS. Type of SDG_PLUS_10%;
    SDAPLUS20 EXPOSURE_GMR_FS. Type of SDG_PLUS_20%;
    SDAPLUS40 EXPOSURE_GMR_FS. Type of SDG_PLUS_40%;
    I have NUMBER: = 0;
    |
    |
    |
    |
    |

    COMMIT;

    END SP_INSERT_FS_DUMP;

    Hello

    After the statement of appeal, i.e. the statement that generated the error.

    Assuming that the package is in user_x scheme, is the right way to call this procedure:

    user_x.sdp.sp_insert_fs_dump (n1, n2, n3, n4);
    

    Is that what you call it?

    You can ignore the name of the owner (user_x) if user_x is your current schema. Normally, this is the case only when you open a session as user_x.

    The name of the package (sdp) can be ignored if you call the procedure from the same package.

  • PLS-00201: identifier 'V_RETURN' must be declared error

    Hello

    I am relatively new to PL/SQL and have created the procedure below inside the packaging. However when I try to run the following...
    execute USERF.MX_API.Insert_Note (40081492,1583970,'Test message',v_Return);
    .... I get the error below.

    ORA-06550: line 1, column 88:
    PLS-00201: identifier 'V_RETURN' must be declared.
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored

    Here is the code for my home, I looked at the permissions for the user USERF and they execute any procedure as a privilege and not defined by a role. I tried to create a public synonym as well even if I call the procedure using the schema.package.procedure method.

    Can anyone help? Very much appreciated.
    CREATE OR REPLACE PACKAGE BODY USERF.MX_API AS
    
      PROCEDURE Insert_Note(v_Account_No IN NUMBER, v_Wo_No IN NUMBER, v_Note_Text IN VARCHAR2, v_Return OUT NUMBER)
      IS
       v_Prime_Uid NUMBER;
       v_String_Length NUMBER;
     v_Temp_String VARCHAR2(2000);
     v_Line_Text VARCHAR2(80);
     v_Line_No NUMBER;
     
      BEGIN
    
     v_Return:=0;
     v_Temp_String:=TRIM(v_Note_Text);
     v_Line_No:=0;
    
       LOOP
      v_String_Length:=LENGTH(v_Temp_String);
       
      IF v_String_Length > 80 THEN
       v_Line_Text:=SUBSTR(v_Temp_String,1,80);
      ELSE
       v_Line_Text:=v_Temp_String;
      END IF;
    
      v_Prime_Uid:=dbp_utl_get_uid('NOTEPAD');
      v_Line_No:=v_Line_No + 1;
    
      INSERT INTO NOTEPADS
       (
       PRIME_UID,
       ACCOUNT_NO,
       NOTE_TYPE,
       LINE_NO,
       LINE_TEXT,
       LINE_USER,
       LINE_DT 
       )
      VALUES (
       v_Prime_Uid,
       v_Account_No,
       'DIRNT',
       v_Line_No,
       v_Line_Text, 
       'C1234',
       SYSDATE 
       );
    
      INSERT INTO WORK_ORDER_NOTE
       (
       WO_NO,
       NOTEPAD_UID
       )
      VALUES (
       v_Wo_No,
       v_Prime_Uid
       );
      
      EXIT WHEN v_String_Length < 81;
    
      v_Temp_String:=SUBSTR(v_Temp_String,81);  
     
     END LOOP;
     
     v_Return:=1;
    
      EXCEPTION
       WHEN OTHERS THEN
      v_Return:=0;
     
      END Insert_Note;
    
    END MX_API;
    /

    Hello

    Try this
    -not tested

    declare
    V_RETURN varchar2 (100);
    Start
    Run USERF. MX_API. Insert_Note (40081492,1583970, 'Test Message', v_Return);
    end;
    /

    Thank you

  • PLS-00201: identifier 'DBMS_SQL' must be declared.

    Windows XP with 10.2.0.1.0

    I have a store procedure contains codes below. As soon as I run the procedure store package he invites me the error
    PLS-00201: identifier 'DBMS_SQL' must be declared. Help, please. Thank you.


    CID: = DBMS_SQL. OPEN_CURSOR;
    DBMS_SQL. PARSE (cid, 'DROP VIEW' | v.tname,)
    DBMS_SQL. Native);
    vValue: = DBMS_SQL. Execute (CID);

    Connect sys as sysdba and grant execute on DBMS_SQL to user_name

  • PLS-00201: identifier 'tablename' must be declared.

    Y at - it to avoid this error, we have privileges through a role?

    We're not supposed to do any operation of grant by ourselves.

    You wouldn't be able to. Those who will have to be granted by a dba.

    A general approach would be to have the owner of the tables to create this package in its own schema.

    Then the needs one owner to grant privileges to run on the packaging for you (and anyone).

  • 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

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

  • 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

  • Cursor of return of (nested) function - PLS-00201: identifier of the CURSOR must be declared

    Hello

    I have a function in which I use nested functions (because I don't want to create objects explicit / external, it is a requirement that I don't have any effect on / I don't want to change).

    In my external function, I use cursor by declaring them in IS-section and then open using the loop for instruction.

    In my inner function / nested, I also want to use a cursor.

    There I also said one like I did in an external function within the section IS of the nested function.

    SQL Developer complains about syntax error (';: wait ").

    When you try to compile the whole process I get the following error:

    "Error (97,14): PLS-00201: identifier 'CURSOR' must be declared '.

    It's my external function starts as:

    CREATE OR REPLACE FUNCTION FN_GENERATE_QUERY_PMT (instance_id_in IN NUMBER, language_in IN VARCHAR2)
    RETURN CLOB
    IS
         CURSOR c_outer IS
          SELECT * FROM BLA;
    

    When it comes to my internal function with the section IS of the external function and stands (inner functions should be at the end of the Section IS to stand behind the statements of variable and cursor, otherwise there will be an error):

    FUNCTION nfn_get_value (num_in IN NUMBER)
          RETURN SYS_REFCURSOR
        IS
          SYS_REFCURSOR c_inner IS
          SELECT *
          FROM BLUB;
        BEGIN
          RETURN c_where_in;
        END;
    

    After that there will be another nested function, then the BEGIN section will appear.

    When looking for 'function returns cursor' I can only find solutions where the cursor is declared in section IS (sometimes its an AS-section o_O * worried *) but wihtoug select, just declare type.

    The cursor focus is added in the Begin block to the way open for instruction. But I don't want to open it yet. I want to open the cursor using the loop statement. I am able to reopen? used can it be two sliders while one will not be closed properly?

    How to fix to return a cursor that I can use in my external function.

    Advice would be appreciated.

    Thanks in advance.

    Maybe I got the soultion
    First of all, I found this thread:

    http://asktom.Oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:5241391331097

    said the following:

    2) a ref cursor is just a cursor.  a ref cursor is just a cursor.  a ref cursor is just a cursor.... (keep saying it over and over
    

    But fortuneately I also found this post:
    http://asktom.Oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:14188501024541

    where thankfully someone shared her knowledge with others:

    In view of this block of code - you may see more "prominent" unlike - any

    How many times you run this block - cursor C will always be select * twice.  The ref

    cursor is not guaranteed.

    Another difference is that a ref cursor can be returned to a client.  a plsql 'cursor cursor.

    cannot be returned to a client.

    Another difference is a cursor can be global - a ref cursor cannot (you cannot set

    them outside a procedure / function)

    Another difference is a ref cursor can be passed to the subroutine - a subroutine

    cursor cannot be.

    This explains why the samples seem always fair with open (Ref) cursor within the section to START.

    I expeceted this (as I wrote in the first post) and ask if the course of opening will be sent back twice or just redirect. I suppose it it reassigns who were just a little in performance.

    But I can't yet find this good explanation of this type anywhere within the documentation and of course I didn't read it all. Shame on me, but I'm always engaged by internet download.

    I would be grateful if someone could say my last statement and leave a comment on double-distribution of the refcursors has reopened.

    Thanks in advance.

  • PLS00201: identify 'OWA_UTIL' must be declared by mistake

    One of the oracle "WSGL" package is in an INVALID state in our database. All trying to compile, it says "PLS-00201: identify 'OWA_UTIL' must be declared '. Exactly this error occurs on a line (owa_util.get_cgi_env ('SERVER_SOFTWARE')) LayoutData. OWA_UTIL package is available and valid in our database and its schema SYS on. Public synonym also created for owa_util. But I have no idea about this error

    Please help me solve this problem...

    Thanks in advance...

    Beginner of PL/SQL.

    It is also granted to the appellant?

    HTH

  • identifier 'DBMS_SCHEDULER' must be declared

    Hi guys,.
    I am trying to create a task using dbms_schedular, but it gives me following error.

    BEGIN
    () dbms_scheduler.create_job
    job_name = > 'test_job ',.
    job_type = > 'PLSQL_BLOCK ',.
    job_action = > ' start an integer; b integer; Sum (a, b); END;',
    job_class = > 'ADMIN',
    start_date = > SYSTIMESTAMP,
    repeat_interval = > ' freq = MINUTELY ",
    End_date = > NULL,
    enabled = > TRUE,
    Comments = > "Job defined entirely by the procedure to CREATE ONE TASK.");
    END;
    /



    ERROR on line 2:
    ORA-06550: line 2, column 2:
    PLS-00201: identifier 'DBMS_SCHEDULER' must be declared.
    ORA-06550: line 2, column 2:
    PL/SQL: Statement ignored

    NOTE: I grants DBA.

    Environment
    Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 under Linux

    Can you guys please help where I am stuck or what's wrong with pl/sql block.

    As the user SYS

    grant execute on DBMS_SCHEDULER TO 
    

    Then try again.

    Best regards

    mseberg

Maybe you are looking for