How to pass an array to a procedure & how to use array in IN clause in SQL

Hi all,
how do i pass an array of varchar2[10] in an procedure and i want to use this array in the IN caluse of the SQL statement inside the procedure. Can anyone please help me on this.
Thanks & regards
shyam~

There are multiple ways. For example:
SQL> create or replace
  2    type str10_tbl_type is table of varchar2(10)
  3  /
Type created.
SQL> -- Using TABLE operator
SQL> create or replace
  2    procedure p1(
  3                 p_str10_tbl str10_tbl_type
  4                )
  5      is
  6      begin
  7          for rec in (
  8                      select  ename,
  9                              sal
10                        from  emp,
11                              table(p_str10_tbl)
12                        where ename = column_value
13                     ) loop
14            dbms_output.put_line(rpad(rec.ename,10) || rec.sal);
15          end loop;
16  end;
17  /
Procedure created.
SQL> set serveroutput on format wrapped
SQL> exec p1(str10_tbl_type('KING','ALLEN','SMITH'));
KING      5000
ALLEN     1600
SMITH     800
PL/SQL procedure successfully completed.
SQL> -- Using MEMBER OF method
SQL> create or replace
  2    procedure p1(
  3                 p_str10_tbl str10_tbl_type
  4                )
  5      is
  6      begin
  7          for rec in (
  8                      select  ename,
  9                              sal
10                        from  emp
11                        where ename member of p_str10_tbl
12                     ) loop
13            dbms_output.put_line(rpad(rec.ename,10) || rec.sal);
14          end loop;
15  end;
16  /
Procedure created.
SQL> set serveroutput on format wrapped
SQL> exec p1(str10_tbl_type('KING','ALLEN','SMITH'));
SMITH     800
ALLEN     1600
KING      5000
PL/SQL procedure successfully completed.
SQL> SY.

Similar Messages

  • How to use a Sybase table in Oracle SQL statement?

    How to use a Sybase table in Oracle SQL statement?
    Sybase version : 11.9.2.4
    Oracle version : 10.2.05
    Thanks.

    user12088323 wrote:
    How to use a Sybase table in Oracle SQL statement?
    Sybase version : 11.9.2.4
    Oracle version : 10.2.05
    Thanks.Any Oracle client connected to the Oracle database can access Sybase data through the <font style="background-color: #FFFFCC">Database Gateway for Sybase</font> (it requires an additional license) or the <font style="background-color: #FFFFCC">Database gateway for ODBC</font> (it's free).
    The Oracle client and the Oracle database can reside on different machines. The gateway accepts connections only from the Oracle database.
    A connection to the gateway is established through a database link when it is first used in an Oracle session. In this context, a connection refers to the connection between the Oracle database and the gateway. The connection remains established until the Oracle session ends. Another session or user can access the same database link and get a distinct connection to the gateway and Sybase database.
    Database links are active for the duration of a gateway session. If you want to close a database link during a session, you can do so with the ALTER SESSION statement.
    To access the Sybase server, you must create a <font style="background-color: #FFFFCC">database link</font>. A public database link is the most common of database links.
    SQL> CREATE PUBLIC DATABASE LINK dblink CONNECT TO
    2  "user" IDENTIFIED BY "password" USING 'tns_name_entry';
    --dblink is the complete database link name.
    --tns_name_entry specifies the Oracle Net connect descriptor specified in the tnsnames.ora file that identifies the gatewayAfter the database link is created you can verify the connection to the Sybase database, as follows:
    SQL> SELECT * FROM DUAL@dblink;
    Configuring Oracle Database Gateway for Sybase
    <font style="background-color: #FFFFCC">{message:id=10649126}</font>

  • How to use for all entires clause while fetching data from archived tables

    How to use for all entires clause while fetching data from archived tables using the FM
    /PBS/SELECT_INTO_TABLE' .
    I need to fetch data from an Archived table for all the entries in an internal table.
    Kindly provide some inputs for the same.
    thanks n Regards
    Ramesh

    Hi Ramesh,
    I have a query regarding accessing archived data through PBS.
    I have archived SAP FI data ( Object FI_DOCUMNT) using SAP standard process through TCODE : SARA.
    Now please tell me can I acees this archived data through the PBS add on FM : '/PBS/SELECT_INTO_TABLE'.
    Do I need to do something else to access data archived through SAP standard process ot not ? If yes, then please tell me as I am not able to get the data using the above FM.
    The call to the above FM is as follows :
    CALL FUNCTION '/PBS/SELECT_INTO_TABLE'
      EXPORTING
        archiv           = 'CFI'
        OPTION           = ''
        tabname          = 'BKPF'
        SCHL1_NAME       = 'BELNR'
        SCHL1_VON        =  belnr-low
        SCHL1_BIS        =  belnr-low
        SCHL2_NAME       = 'GJAHR'
        SCHL2_VON        =  GJAHR-LOW
        SCHL2_BIS        =  GJAHR-LOW
        SCHL3_NAME       =  'BUKRS'
        SCHL3_VON        =  bukrs-low
        SCHL3_BIS        =  bukrs-low
      SCHL4_NAME       =
      SCHL4_VON        =
      SCHL4_BIS        =
        CLR_ITAB         = 'X'
      MAX_ZAHL         =
      tables
        i_tabelle        =  t_bkpf
      SCHL1_IN         =
      SCHL2_IN         =
      SCHL3_IN         =
      SCHL4_IN         =
    EXCEPTIONS
       EOF              = 1
       OTHERS           = 2
       OTHERS           = 3
    It gives me the following error :
    Index for table not supported ! BKPF BELNR.
    Please help ASAP.
    Thnaks and Regards
    Gurpreet Singh

  • How to use bulk collect into clause

    hi all,
    i have requirement like this i want to change the query by passing the different table names in oracle database 10gr2.
    like if i use first i pass the scott.emp table name select * from scott.emp;
    then i want pass scott.dept table name select * from scott.dept;
    using select * option in the select list.
    how can i execute it.
    give me any solution.
    please reply....

    Hi,
    i recently also ran into some serious trouble to make dynamic sql work.
    It was about parallel pipelined function with strongly typed cursor (for "partition ... by hash(...)").
    But in addition requiring dynamic SQL for the input to this cursor.
    I couldn't make it work with execute immediate or something else.
    So i used another way - I translated dynamic SQL into dynamically created static SQL:
    1. create a base SQL data object type with abstract interface for code (e.g. some Execute() member function).
    2. dynamically create a derived SQL data object type with concrete implementation of Execute() holding your "dynamic SQL" "in a static way"
    3. delegate to Execute().
    Let me quote my example from comp.databases.oracle.server, thread "dynamically created cursor doesn't work for parallel pipelined functions"
    - pls. see below (it's an old one - with likely some odd stuff inside).
    It might sound some kind of strange for DB programmer.
    (I come from C++. Though this is not an excuse smile)
    Maybe i just missed another possible option to handle the problem.
    And it's a definitely verbose.
    But i think it's at least a (last) option.
    Actually i would be interested to hear, what others think about it.
    best regards,
    Frank
    --------------- snip -------------------------
    drop table parallel_test;
    drop type MyDoit;
    drop type BaseDoit;
    drop type ton;
    create type ton as table of number;
    CREATE TABLE parallel_test (
    id NUMBER(10),
    description VARCHAR2(50)
    BEGIN
    FOR i IN 1 .. 100000 LOOP
    INSERT INTO parallel_test (id, description)
    VALUES (i, 'Description or ' || i);
    END LOOP;
    COMMIT;
    END;
    create or replace type BaseDoit as object (
    id number,
    static function make(p_id in number)
    return BaseDoit,
    member procedure doit(
    p_sids in out nocopy ton,
    p_counts in out nocopy ton)
    ) not final;
    create or replace type body BaseDoit as
    static function make(p_id in number)
    return BaseDoit
    is
    begin
    return new BaseDoit(p_id);
    end;
    member procedure doit(
    p_sids in out nocopy ton,
    p_counts in out nocopy ton)
    is
    begin
    dbms_output.put_line('BaseDoit.doit(' || id || ') invoked...');
    end;
    end;
    -- Define a strongly typed REF CURSOR type.
    CREATE OR REPLACE PACKAGE parallel_ptf_api AS
    TYPE t_parallel_test_row IS RECORD (
    id1 NUMBER(10),
    desc1 VARCHAR2(50),
    id2 NUMBER(10),
    desc2 VARCHAR2(50),
    sid NUMBER
    TYPE t_parallel_test_tab IS TABLE OF t_parallel_test_row;
    TYPE t_parallel_test_ref_cursor IS REF CURSOR RETURN
    t_parallel_test_row;
    FUNCTION test_ptf (p_cursor IN t_parallel_test_ref_cursor)
    RETURN t_parallel_test_tab PIPELINED
    PARALLEL_ENABLE(PARTITION p_cursor BY any);
    END parallel_ptf_api;
    SHOW ERRORS
    CREATE OR REPLACE PACKAGE BODY parallel_ptf_api AS
    FUNCTION test_ptf (p_cursor IN t_parallel_test_ref_cursor)
    RETURN t_parallel_test_tab PIPELINED
    PARALLEL_ENABLE(PARTITION p_cursor BY any)
    IS
    l_row t_parallel_test_row;
    BEGIN
    LOOP
    FETCH p_cursor
    INTO l_row;
    EXIT WHEN p_cursor%NOTFOUND;
    select userenv('SID') into l_row.sid from dual;
    PIPE ROW (l_row);
    END LOOP;
    RETURN;
    END test_ptf;
    END parallel_ptf_api;
    SHOW ERRORS
    PROMPT
    PROMPT Serial Execution
    PROMPT ================
    SELECT sid, count(*)
    FROM TABLE(parallel_ptf_api.test_ptf(CURSOR(SELECT t1.id,
    t1.description, t2.id, t2.description, null
    FROM parallel_test t1,
    parallel_test t2
    where t1.id = t2.id
    ) t2
    GROUP BY sid;
    PROMPT
    PROMPT Parallel Execution
    PROMPT ==================
    SELECT sid, count(*)
    FROM TABLE(parallel_ptf_api.test_ptf(CURSOR(SELECT /*+
    parallel(t1,5) */ t1.id, t1.description, t2.id, t2.description, null
    FROM parallel_test t1,
    parallel_test t2
    where t1.id = t2.id
    ) t2
    GROUP BY sid;
    PROMPT
    PROMPT Parallel Execution 2
    PROMPT ==================
    set serveroutput on;
    declare
    v_sids ton := ton();
    v_counts ton := ton();
    -- v_cur parallel_ptf_api.t_parallel_test_ref_cursor;
    v_cur sys_refcursor;
    procedure OpenCursor(p_refCursor out sys_refcursor)
    is
    begin
    open p_refCursor for 'SELECT /*+ parallel(t1,5) */ t1.id,
    t1.description, t2.id, t2.description, null
    FROM parallel_test t1,
    parallel_test t2
    where t1.id = t2.id';
    end;
    begin
    OpenCursor(v_cur);
    SELECT sid, count(*) bulk collect into v_sids, v_counts
    FROM TABLE(parallel_ptf_api.test_ptf(v_cur)) t2
    GROUP BY sid;
    for i in v_sids.FIRST.. v_sids.LAST loop
    dbms_output.put_line (v_sids(i) || ', ' || v_counts(i));
    end loop;
    end;
    PROMPT
    PROMPT Parallel Execution 3
    PROMPT ==================
    set serveroutput on;
    declare
    instance BaseDoit;
    v_sids ton := ton();
    v_counts ton := ton();
    procedure CreateMyDoit
    is
    cmd varchar2(4096 char);
    begin
    cmd := 'create or replace type MyDoit under BaseDoit ( ' ||
    ' static function make(p_id in number) ' ||
    ' return MyDoit, ' ||
    ' overriding member procedure doit( ' ||
    ' p_sids in out nocopy ton, ' ||
    ' p_counts in out nocopy ton) ' ||
    execute immediate cmd;
    cmd := 'create or replace type body MyDoit as ' ||
    ' static function make(p_id in number) ' ||
    ' return MyDoit ' ||
    ' is ' ||
    ' begin ' ||
    ' return new MyDoit(p_id); ' ||
    ' end; ' ||
    ' ' ||
    ' overriding member procedure doit( ' ||
    ' p_sids in out nocopy ton, ' ||
    ' p_counts in out nocopy ton) ' ||
    ' is ' ||
    ' begin ' ||
    ' dbms_output.put_line(''MyDoit.doit('' || id || '')
    invoked...''); ' ||
    ' SELECT sid, count(*) bulk collect into p_sids, p_counts ' ||
    ' FROM TABLE(parallel_ptf_api.test_ptf(CURSOR( ' ||
    ' SELECT /*+ parallel(t1,5) */ t1.id, t1.description,
    t2.id, t2.description, null ' ||
    ' FROM parallel_test t1, parallel_test t2 ' ||
    ' where t1.id = t2.id ' ||
    ' ))) ' ||
    ' GROUP BY sid; ' ||
    ' end; ' ||
    ' end; ';
    execute immediate cmd;
    end;
    begin
    CreateMyDoit;
    execute immediate 'select MyDoit.Make(11) from dual' into instance;
    instance.doit(v_sids, v_counts);
    if v_sids.COUNT > 0 then
    for i in v_sids.FIRST.. v_sids.LAST loop
    dbms_output.put_line (v_sids(i) || ', ' || v_counts(i));
    end loop;
    end if;
    end;
    --------------- snap -------------------------

  • How to use create-default-dbms-tables in SQL Server 2000

    Hi everyone,
    I'm new in EJB development. I'm trying to deploy a CMP to Weblogic 8.1 SP1 using
    JBuilderX. I configured a ConnectionPool and DataSource to allow the CMP to access
    the SQL Server 2000. However, I cannot deploy the CMP if I didn't create the table
    in SQL Server manually. Does anyone know how to use the create-default-dbms-tables?

    Refer to
    http://e-docs.bea.com/wls/docs81/ejb/DDreference-cmp-jar.html#1162249
    "Keith" <[email protected]> wrote:
    >
    Hi everyone,
    I'm new in EJB development. I'm trying to deploy a CMP to Weblogic 8.1
    SP1 using
    JBuilderX. I configured a ConnectionPool and DataSource to allow the
    CMP to access
    the SQL Server 2000. However, I cannot deploy the CMP if I didn't create
    the table
    in SQL Server manually. Does anyone know how to use the create-default-dbms-tables?

  • Procedure failed while using bulk collect into clause and works with cursor

    hi all,
    I am using "BULK collect into" clause in my procedure and it is failing after 21 minutes and gives the error "end of file communication channel".
    after this error comes when i tried to connect database it is giving following error.
    ORA -01034 - Oracle not available.
    ORA- 27101 - shared memory realm does not exist.
    svr4- error :2 : No such file or directory.
    when i use cursor instead of BULK COLLECT INTO clause it is running successful.
    Following code is working with cursor.
    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, '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
    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(+);
    BEGIN
    execute immediate 'truncate table crstools.drt_bom_work_kiosk';
    select sysdate into ld_curr_time from dual;
    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
    ,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
    (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
    ,cur_rec.BILLABLE
    ,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.ECD
    ,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.REPAIR_DESCRIPTION
    ,cur_rec.REQUESTOR
    ,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.SHIFT
    ,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
    when 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 bulk collect into caluse.
    Please help me out why this is happening.
    Thanks & regards
    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 were changing the data being inserted in such a way that you couldn't encapsulate the changes in a query, but you are doing a straight insert into the table from your Cursor. A much more efficient way would be to use the following modifications I made to your code example:
    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's the link for infor on the [Oracle Direct-Path INSERT |http://download.oracle.com/docs/cd/B10501_01/server.920/a96524/c21dlins.htm#10778].
    Also, if you are truly intent on using a CURSOR FOR LOOP with the BULK COLLECT, I suggest you read Steven Feuerstein's article [PL/SQL Practices: On BULK COLLECT |http://www.oracle.com/technology/oramag/oracle/08-mar/o28plsql.html].
    Hope this helps.
    Craig...
    If my response or the response of another was helpful, please mark it accordingly

  • How to use circular linked list in pl/sql?

    Hi all,
    how to use the circular linked list on pl/sql programming.
    thanks in advance
    Rgds,
    B@L@

    d balamurugan wrote:
    Hi,
    I needed this concept for the below example
    TABLE_A have the columns of
    ID COL_1 COL_2 COL_3 COL_4 COL_5 COL_6 COL_7
    1....Y.........N........N.........Y........ N........N........ N
    2....N.........N....... N.........Y.........N........N.........Y
    in the above data
    for id 1 i will need to take the value for COL_4, then i will check the next availability of Y through out through out the remaining columns, so next availability is on COL_1 so, i need to consider COL_4 which already Y and also i need to consider COL_5, COL_6, COL_7 as Y.
    for id 2 if i need COL_7 then i need to come back on circular way and need to check the next availability of Y and need to take the columns having N before the next availability of YAnd... even after all that description... you haven't given any indication of what the output should look like.
    Taking a wild guess on my part... something like this would do what you appear to be asking...
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (select 1 as id, 'Y' as col1, 'N' as col2, 'N' as col3, 'Y' as col4, 'N' as col5, 'N' as col6,'N' as col7 from dual union all
      2             select 2, 'N', 'N', 'N', 'Y', 'N', 'N', 'Y' from dual)
      3  --
      4  -- END OF TEST DATA
      5  --
      6  select id
      7        ,rcol
      8        ,case when instr(cols,'Y',rcol+1) = 0 then instr(cols,'Y')
      9              else instr(cols,'Y',rcol+1)
    10         end as next_Y_col
    11  from   (select id, rcol, col1||col2||col3||col4||col5||col6||col7 as cols
    12          from t, (select &required_col as rcol from dual)
    13          where id = &required_id
    14*        )
    SQL> /
    Enter value for required_col: 4
    old  12:         from t, (select &required_col as rcol from dual)
    new  12:         from t, (select 4 as rcol from dual)
    Enter value for required_id: 1
    old  13:         where id = &required_id
    new  13:         where id = 1
            ID       RCOL NEXT_Y_COL
             1          4          1
    SQL> /
    Enter value for required_col: 7
    old  12:         from t, (select &required_col as rcol from dual)
    new  12:         from t, (select 7 as rcol from dual)
    Enter value for required_id: 2
    old  13:         where id = &required_id
    new  13:         where id = 2
            ID       RCOL NEXT_Y_COL
             2          7          4
    SQL>If that's not what you want... then it's time you started learning how to ask questions properly.

  • How to use get column name.vi in SQL toolkit 2.0?

    Due to the vi "get column name.vi" paremeters,no table name has connected to the vi. So, I want to ask how to use this vi for gain one column name of a table. Maybe there are some other ways to solve column name getting.
    Thanks.

    Thanks!
    Error 4101 Description:
    Execute SQL - The connection, statement, or query handle you provided is not valid.
    I don't just used the toolkit in a while,now, I am developing a irrigation system. For the table field names defined by users,column names must be known before any select operations. Do you have any other good idea about drawing out the columnname parameters?
    As you know, a valid DSN and table have been also available. The database I used is Access. The bad thing to me is that there is no any text information gotten. And I think, it may be some problems in connection way which I don't find out.
    Really appreciated by your reply.
    Could you give me some example in the aspect?
    Thank you again.

  • How  to Pass String array from Java to PL/SQL  and this use in CURSOR

    hi,
    I cant understand how to pass Array String as Input Parameter to the Procedure and this array use in Cursor for where condition like where SYMPTOM in( ** Array String **).
    This array containing like (SYMPTOM ) to be returned from the java to the
    pl/sql (I am not querying the database to retrieve the information).
    I cannot find an example on this. I will give the PL/SQL block
    create or replace procedure DISEASE_DTL<*** String Array ***> as
    v_SYMPTOM number(5);
    CURSOR C1 is
    select distinct a.DISEASE_NAME from SYMPTOM_DISEASE_RD a
    where ltrim(rtrim(a.SYMPTOM)) in ('Fever','COUGH','Headache','Rash') ------- ***** Here use this array element(like n1,n2,n3,n4,n5..) ******
    group by a.DISEASE_NAME having count(a.DISEASE_NAME) > 3 ----------- ***** 3 is no of array element - 1 (i.e( n - 1))*****
    order by a.DISEASE_NAME ;
    begin
    for C1rec IN C1 loop
    select count(distinct(A.SYMPTOM)) into v_SYMPTOM from SYMPTOM_DISEASE_RD a where A.DISEASE_NAME = C1rec.DISEASE_NAME;
    insert into TEMP_DISEASE_DTLS_SYMPTOM_RD
    values (SL_ID_SEQ.nextval,
    C1rec.DISEASE_NAME,
    (4/v_SYMPTOM), --------**** 4 is no of array element (n)************
    (1-(4/v_SYMPTOM)));
    end loop;
    commit;
    end DISEASE_DTL;
    Please give the proper solution and step ..
    Thanking you,
    Asish

    I've haven't properly read through your code but here's an artificial example based on a sql collection of object types - you don't need that, you just need a type table of varchar2 rather than a type table of oracle object type:
    http://orastory.wordpress.com/2007/05/01/upscaling-your-jdbc-app/

  • Passing an array of beans to PL/SQL proc - can't quite figure it out

    Hi
    I'm trying to pass in a Java array of beans to a PL/SQL proc and I can't quite get it to work. I did have the more simple case of an array of strings working but I'm stumped as to how to get this more complicated case to work.
    I'm using Java 5 and Oracle 10.
    My Oracle User Defined Types
    create or replace type MY_OBJECT as object (
          id integer,
          join_table_name varchar(30)
    create or replace type MY_OBJECT_ARRAY as table of MY_OBJECT;
    My PL/SQL proc
    create or replace package threshold is
      function validateThresholdSequence (
          thresholdSeqId integer,
          testValue number,
          testDate date,
          validationCriteria in MY_OBJECT_ARRAY
      ) return number;
    end;
    My Java
      public class ThresholdValidationCriteriaBean
        private String joinTableName = null;
        private Integer id = null;
        //Getters and setters...
      //Map my bean to the PL/SQL UDT - thought this might help but it seems not!
      Map<String, Class<?>> map = c.getTypeMap();
      map.put("MY_OBJECT", ThresholdValidationCriteriaBean.class);
      //Prepair my statement
      String sql=new String("{call threshold.validateThresholdSequence(?,?,?,?) }");
      ps= c.prepareStatement(sql);
      // Set the values to insert
      ps.setInt(1, thresholdSequenceId);
      ps.setDouble(2, testValue);
      ps.setDate(3, new java.sql.Date(date.getTime()));
      //Sort out the array thing
      ArrayDescriptor desc = ArrayDescriptor.createDescriptor("MY_OBJECT_ARRAY", c);
      ThresholdValidationCriteriaBean[] beanArray = new ThresholdValidationCriteriaBean[validationCriteria.size()];
      validationCriteria.toArray(beanArray);
      ARRAY array = new ARRAY (desc, c, beanArray);
      ((oracle.jdbc.driver.OraclePreparedStatement)ps).setARRAY(4, array); When I run this I get the following error on the creation of the ARRAY object
    java.sql.SQLException: Fail to convert to internal representation: uk.co.cartesian.ascertain.imm.threshold.ThresholdValidationCriteriaBean@15c7850
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
         at oracle.jdbc.oracore.OracleTypeADT.toDatum(OracleTypeADT.java:239)
         at oracle.jdbc.oracore.OracleTypeADT.toDatumArray(OracleTypeADT.java:274)
         at oracle.jdbc.oracore.OracleTypeUPT.toDatumArray(OracleTypeUPT.java:115)
         at oracle.sql.ArrayDescriptor.toOracleArray(ArrayDescriptor.java:1314)
         at oracle.sql.ARRAY.<init>(ARRAY.java:152)I've spent most of the day so far going from one error to the next - but I seem to be stuck now.
    Any help or hints very much appreciated
    Cheers
    Ian
    Edited by: Yanis on Feb 28, 2008 12:12 PM

    I've found the answer - I'll put the code here so everyone else can see what seems to work for me
    First off the object that is being passed into the array needs to implement a couple of interfaces and so becomes
    public class ThresholdValidationCriteriaBean
    implements SQLData, Serializable
        private String joinTableName = null;
        private Integer id = null;
        //Getters and Setters
        public String getSQLTypeName()
        throws SQLException
            return "MY_OBJECT";
        public void readSQL(SQLInput stream, String typeName)
            //No need to implement this
        public void writeSQL(SQLOutput stream)
            //No need to implement this
    }The code that I used to call the PL/SQL procedure with an array of MY_OBJECT's is
                //Sort out our array stuff
                ArrayDescriptor desc = ArrayDescriptor.createDescriptor("MY_OBJECT_ARRAY", c);
                ThresholdValidationCriteriaBean[] ba = new ThresholdValidationCriteriaBean[validationCriteria.size()];
                //Populate array
                ARRAY arrayToPass = new ARRAY (desc, c, ba);
                //Create our statement
                String sql = new String("{call ? := threshold.validateThresholdSequence(?,?,?,?) }");
                ps = c.prepareCall(sql);
                //Register our out parameter
                ((oracle.jdbc.OracleCallableStatement)ps).registerOutParameter(1, Types.INTEGER);
                // Set the values to insert
                ps.setInt(2, thresholdSequenceId);
                ps.setDouble(3, testValue);
                ps.setDate(4, new java.sql.Date(date.getTime()));
                ((oracle.jdbc.driver.OraclePreparedStatement)ps).setARRAY(5, arrayToPass);
                //Execute call to PL/SQL
                ps.execute(); Edited by: Yanis on 10-Mar-2008 13:17

  • Passing an array from Java to Pl/SQL Procdures

    I am relatively new to the Java world and I am unable to pass back an array from Java back to the calling PL/SQL procedure. I have read many of the posts that deal with this issue and in specificly have viewed Ask Tom. My main issue is trying to get the data types matched up. I am able to return varchar2, numbers, and the like, but an array of filenames is not happening. I have tried a variety of "types" but unable to accomplish the task. Please help.
    I have my Java class basically defined as:
    public static oracle.sql.ARRAY[] getCollection(String directory)
                   throws SQLException
    { // provide a directory and get a listing of files
    File path = new File( directory );
    String[] list = path.list();
    return list;
    SQL Type and PL/SQL Procedure is:
    CREATE OR REPLACE TYPE PTO_FILE IS TABLE OF VARCHAR2(100);
    create or replace function get_dir_collection( p_directory in varchar2 ) RETURN PTO_FILE
         as language java
    name 'DirCollection.getCollection( java.lang.String ) return oracle.sql.ARRAY[]';
    /

    I know that it is not an ARRAY. It is however an "array" and I am attempting to map Java's String[][ to some "object" on the oracle side.  I have looked at the link you sited and was not able to find the data mapping.  I have found that mapping data types between different "languages" is some of the most difficult aspects of working with multiple languages.
    Any suggestions? Thanks

  • Passing String Array from Java to PL/SQL

    Hi,
    We are having couple of packages which have been written in PL/SQL . I would like to know how i can send arrays as input parameters from Java to any stored proc in Oracle. I am having Oracle 8i as the DB and am using Websphere RSA for deployment purposes.
    please find below Java , PL/SQL code and exception
    PL/SQL Code :
    PACKAGE PKG_SURCHARGE
    IS
    TYPE commodity_key IS TABLE OF VARCHAR2(500) INDEX BY BINARY_INTEGER;
    PROCEDURE RETRIEVE_CHARGES
    in_Commodity_tab IN commodity_key,
    IS
    BEGIN
    dbms_output.put_line('in_Commodity_tab(' || '0' || ') : ' || in_Commodity_tab(0) );
    Java Code :
    CallableStatement cstmt=null;
    Connection conn=null;
    try{
    conn=getConnection();
    System.out.println("++++++connected");
    String sqlStr = "{call Pkg_Surcharge.RETRIEVE_CHARGES(?) }";
    cstmt = conn.prepareCall(sqlStr );
    //1.
    String[] javaArray={"20081117","20081117"};
    ArrayDescriptor dateDescripter = ArrayDescriptor.createDescriptor( "commodity_key", conn );
    oracle.sql.ARRAY dateArray = new oracle.sql.ARRAY(dateDescripter, conn, javaArray);
    System.out.println("++++++registered-1");
    Catch (Exception e){
    e.printStackTrace();
    Exception Occured:
    java.sql.SQLException: Invalid Pattern Name <Schema Name>.commodity_key
    Appreciate your help in this regard
    Thanks
    Srini
    Edited by: [email protected] on Nov 25, 2008 4:55 AM

    Avi is correct. You must create a varray or nested table instead of using a PL/SQL index-by table.
    SQL> create type commodity_key as varray(#) of varchar2(500);
    or
    SQL> create type commodity_key as table of varchar2(500);
    Use the varray if you know the number of items in the array. Otherwise, use the nested table.

  • Passing a table into a procedure to be used in a curor

    Hi,
    I'm using Oracle 9.2.0.6
    I have a procedure that searches all objects for a passed in string value. The procedure is below.
    CREATE OR REPLACE PROCEDURE Find_String (
    pin_referenced_name IN dba_dependencies.referenced_name%TYPE)
    IS
    cursor cur_get_dependancy
    is
    SELECT distinct owner, name, type
      FROM [email protected]
    WHERE lower(referenced_name) = lower(pin_referenced_name) --'ftbv_salesrep_all_1d'
       AND referenced_type != 'SYNONYM'
    order by name;
    v_owner  varchar2(40);
    v_name   varchar2(50);
    v_type   varchar2(40);
        BEGIN
           dbms_output.put_line(upper(pin_referenced_name)||' is found in the following objects.');
           dbms_output.put_line(' ');
           dbms_output.put_line(RPAD('OWNER', 30, ' ')||RPAD('NAME', 60, ' ')||RPAD('OBJECT TYPE', 30, ' '));
           dbms_output.put_line('-------------------------------------------------------------------------------------------------------------------');
            FOR i IN cur_get_dependancy
            LOOP
                v_owner := RPAD(i.owner, 30, ' ');
                v_name  := RPAD(i.name, 45, ' ');
                v_type  := RPAD(i.type, 30, ' ');
                dbms_output.put_line(v_owner ||v_name|| v_type);
            END LOOP;
    END find_string;I was wondering if there's any way I could pass in the table name, and the name of the DB link to be used in the cursor, into the procedure and rig the cursor to be able to accept that as a parameter. I want our users to be able to search different databases using this utility code.
    I thought of NDS, and that would be a way to do it, however I'm not sure if I could use an NDS statement in conjunction with a cursor.
    Does anybody have any suggestions?
    Thanks

    One approach (there are obviously many ways to skin this particular cat)
    SQL> ed
    Wrote file afiedt.buf
      1  declare
      2    c1           sys_refcursor;
      3    l_val        number;
      4    l_table_name varchar2(30) := 'dual';
      5  begin
      6    open c1 for 'select 1 from ' || l_table_name;
      7    loop
      8      fetch c1 into l_val;
      9      exit when c1%notfound;
    10      dbms_output.put_line( l_val );
    11    end loop;
    12    close c1;
    13* end;
    SQL> /
    1
    PL/SQL procedure successfully completed.Justin

  • How to use a parameter in an Execute SQL Tasks in SSDT executed against Netezza

    Good Evening,
    How can I pass a parameter in an Execute SQL Tasks in SSDT executed against Netezza?  Below are my settings and error message.
    [Execute SQL Task] Error: Executing the query ""TRUNCATE TABLE" ?"_POC..JOHN_TEST"" failed with the following error: "Syntax error or access violation". Possible failure reasons: Problems with the query, "ResultSet"
    property not set correctly, parameters not set correctly, or connection not established correctly.
    Thank you in advance for your assistance.
    Brett

    Hi Baloun,
    Based on my further research, just as you said, we cannot directly use table name as a variable.
    To fix this issue, we can change the SQL command in the SQLStatement property as below:
    declare @sql varchar(100)
    set @sql = 'TRUNCATE TABLE ' + ? +'_POC..JOHN_TEST'
    exec(@sql)
    go
    The Parameter Mapping pane use the former settings in your picture.
    Reference:
    http://www.bidn.com/blogs/kylewalker/ssis/2063/parameters-don-t-always-work-in-your-execute-sql-task
    If there are any other questions, please feel free to ask.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • How to use concatenated sequence name in pl/sql

    how can we have a sequence concatenated with another sequence
    name eg
    select ab.nextvalue into var1 from dual;
    where a is a sequence and b is another sequence
    null

    Try this Puneet:
    TO_NUMBER(TO_CHAR(a.nextvalue)

Maybe you are looking for

  • BATTERY LIFE IS HORRIBLE

    I was wondering if I was the only one with this issue. I mean I charged the phone last night. Browsed through the internet like 6 sites less than 30 minutes on all of them on my WIFI not even edge. did 2 calls totalling 20 minutes through out the day

  • How to get Purchased Ringtones back on iphone, How to get Purchased Ringtones back on iphone

    I purchased 4-5 ringtones over a period of time and got my phone replaced in england since then i dont have them on my phone how do it get them back ? Please help

  • Bad PBR sig and dual booting with Windows

    This site's menu config is too difficult for me... fyi. => Below is the cases that happened in my environment when installing Solaris 8 Operating Environment, Intel Platform Edition Some will help you, and some may be just for your thinking. Bad PBR

  • Urgent!  Please HELP with EBCC sycn!!

    I recently upgraded to portal 4.0 sp2 and ebcc sp2. When I tried to sync to one of our production server, I got this error: Jul 22, 2002 10:53:14 AM CDT patientPortalServe Error Data Synchronizati Application: patientportal; No message available. Res

  • How to convert this SQL query to PL/SQL

    I basically need to create an anonymous block that will display each student's first name, last name and the count of students who scored less on test 1 than the student. So basically we need to find the count of students who have scored less than th