How to bypass FORALL in SELECT .. BULK COLLECT

Using Oracle 8.1.7
I developed a stored procedure LOT
TYPE TIds IS Table of Integer;
TYPE TFloats IS Table of Float;
procedure LOT(Ids TIds) ....
is
Prices TFloats;
Quantities TFloats;
begin
for I in 1..Ids.Count loop
SELECT ...
BULK COLLECT INTO Prices, Quantities, ...
WHERE ... = Ids(I)
end loop;
end;
For each Id from IDS collection my procedure SELECTs several
rows (avg. 2 or 3 rows). IDS contains about 1000 - 10000 items.
Productivity is very low.
Because is the many context switches
between SQL engine and PL/SQL engine.
The point is to collect all data by single 'huge' SELECT instead
of numerous 'short' SELECTs.
I. e. I need somethng like
FORALL I in 1..Ids.Count
SELECT ...
BULK COLLECT INTO Prices, Quantities, ...
WHERE ... = Ids(I)
or like this
FORALL I in 1..Ids.Count
SELECT ...
WHERE ... = Ids(I) RETURNING ... BULK COLLECT INTO ...
I know it's invalid syntax because PL/SQL doesn't support BULK
COLLECT clause for SELECT in FORALL loop.
How should I bypass the problem?
Is a proper way to use temporary table as storehouse for IDS collection?
Something else?
Regards,
Piter Elagin (AlienZzzz)

Hi Ivan,
   the problem is that the port is configurable at installation time.  On a NetWeaver 04 portal, I believe the default was 50000.  That should get you to one of the servers.  You may try 50100, 50200, etc. 
You can also ask who ever did the installation.  the other place to look is the webdispatcher configuration file.  It would have to know the server and port to dispatch to.
Hope that helps.
John

Similar Messages

  • How can I fill a table of objects from cursor with select * bulk collect???

    Hi All, I have a TYPE as OBJECT
    create or replace type dept2_o as object (
    deptno NUMBER(2),
    dname VARCHAR2(14),
    loc VARCHAR2(13));
    I can fill a table of objects from cursor with out select * bulk collect...., row by row
    declare
    TYPE dept2_t IS TABLE of dept2_o;
    dept_o_tab dept2_t:=dept2_t();
    i integer;
    begin
    i:=0;
    dept_o_tab.extend(20);
    for rec in (select * from dept) loop
    i:=i+1;
    dept_o_tab(i):=dept2_o(
    deptno => rec.deptno,
    dname => rec.dname,
    loc =>rec.loc
    end loop;
    for k IN 1..i loop
    dbms_output.put_line(dept_o_tab(k).deptno||' '||dept_o_tab(k).dname||' '||dept_o_tab(k).loc);
    end loop;
    end;
    RESULT
    10 ACCOUNTING NEW YORK
    20 RESEARCH DALLAS
    30 SALES CHICAGO
    40 OPERATIONS BOSTON
    But I can't fill a table of objects from cursor with select * bulk collect construction ...
    declare
    TYPE dept2_t IS TABLE of dept2_o;
    dept_o_tab dept2_t:=dept2_t();
    begin
    dept_o_tab.extend(20);
    select * bulk collect into dept_o_tab from dept;
    end;
    RESULT
    ORA-06550: line 6, column 39;
    PL/SQL: ORA-00947: not enough values ....
    How can I fill a table of objects from cursor with select * bulk collect???

    create or replace type dept_ot as object (
    deptno NUMBER(2),
    dname VARCHAR2(14),
    loc VARCHAR2(13));
    create table dept
    (deptno number
    ,dname varchar2(14)
    ,loc varchar2(13)
    insert into dept values (10, 'x', 'xx');
    insert into dept values (20, 'y', 'yy');
    insert into dept values (30, 'z', 'zz');
    select dept_ot (deptno, dname, loc)
      from dept
    create type dept_nt is table of dept_ot
    declare
       l_depts dept_nt;
    begin
       select dept_ot (deptno, dname, loc)
         bulk collect
         into l_depts
         from dept
       for i in l_depts.first .. l_depts.last
       loop
          dbms_output.put_line (l_depts(i).deptno);
          dbms_output.put_line (l_depts(i).dname);
          dbms_output.put_line (l_depts(i).loc);    
       end loop;
    end;
    /

  • How to use table type in bulk collect

    Hi experts,
    How to use table type in bulk collect see the procedure used( oracle 10g)
    and error is
    PLS-00597: expression 'REQ_REC' in the INTO list is of wrong type
    CREATE OR REPLACE PROCEDURE SAMPLE_SP IS
    TYPE TYP_A AS OBJECT
    ( COLMN1 TABLE1.COLM1%TYPE,
    COLMN2 TABLE1.COLM2%TYPE,
    COLMN3 TABLE1.COLM3%TYPE
    TYPE REC_A IS TABLE OF TYP_A;
    REQ_REC A_REC;
    CURSOR REQ_CUR IS SELECT COLM1,COLM2,COLM3 FROM TABLE1 WHERE <CONDITION>;
    BEGIN
    OPEN REQ_REC;
    LOOP
    EXIT WHEN REQ_REC%NOTFOUND;
    FETCH REQ_REC BULK COLLECT INTO REQ_REC LIMIT 1000;
    FOR I IN 1..REQ_REC.COUNT
    LOOP
    <insert statement>
    END LOOP;
    COMMIT;
    END LOOP;
    END SAMPLE_SP;
    Many thanks,
    Kalinga

    ok but that is not an issue..
    Hi experts,
    How to use table type in bulk collect see the procedure used( oracle 10g)
    and error is
    PLS-00597: expression 'REQ_REC' in the INTO list is of wrong type
    CREATE OR REPLACE PROCEDURE SAMPLE_SP IS
    TYPE TYP_A AS OBJECT
    ( COLMN1 TABLE1.COLM1%TYPE,
    COLMN2 TABLE1.COLM2%TYPE,
    COLMN3 TABLE1.COLM3%TYPE
    TYPE REC_A IS TABLE OF TYP_A;
    REQ_REC A_REC;
    CURSOR REQ_CUR IS SELECT COLM1,COLM2,COLM3 FROM TABLE1 WHERE <CONDITION>;
    BEGIN
    OPEN REQ_CUR;
    LOOP
    EXIT WHEN REQ_REC%NOTFOUND;
    FETCH REQ_REC BULK COLLECT INTO REQ_REC LIMIT 1000;
    FOR I IN 1..REQ_REC.COUNT
    LOOP
    <insert statement>
    END LOOP;
    COMMIT;
    END LOOP;
    END SAMPLE_SP;
    Many thanks,
    Kalinga
    Message was edited by:
    Kalinga

  • How to handle multiple save exceptions (Bulk Collect)

    Hi
    How to handle Multiple Save exceptions? Is it possible to rollback to first deletion(of child table) took place in the procedure.
    There are 3 tables
    txn_header_interface(Grand Parent)
    orders(parent)
    order_items (Child)
    One transaction can have one or multiple orders in it.
    and one orders can have one or multiple order_items in it.
    We need to delete the data from child table first then its parent and then from the grand parent table.if some error occurs anywhere I need to rollback to child record deletion. Since there is flag in child table which tells us when to delete data from database.
    Is it possible to give name to Save exceptions?
    e.g.
    FORALL i IN ABC.FIRST..ABC.LAST SAVE EXCEPTIONS A
    FORALL i IN abc.FIRST..ABC.LAST SAVE EXCEPTIONS B
    if some error occurs then
    ROLLBACK A; OR ROLLBACK B;
    Please find the procedure attached
    How to handle the errors with Save exception and rollback upto child table deletion.
    CREATE OR REPLACE
    PROCEDURE DELETE_CONFIRMED_DATA IS
    TYPE TXN_HDR_INFC_ID IS TABLE OF TXN_HEADER_INTERFACE.ID%TYPE;
    TXN_HDR_INFC_ID_ARRAY TXN_HDR_INFC_ID;
    ERROR_COUNT NUMBER;
    BULK_ERRORS EXCEPTION;
    PRAGMA exception_init(bulk_errors, -24381);
    BEGIN
    SELECT THI.ID BULK COLLECT
    INTO TXN_HDR_INFC_ID_ARRAY
    FROM TXN_HEADER_INTERFACE THI,ORDERS OS,ORDER_ITEMS OI
    WHERE THI.ID = OS.TXN_HDR_INFC_ID
    AND OS.ID = OI.ORDERS_ID
    AND OI.POSTING_ITEM_ID = VPI.ID
    OI.DW_STATUS_FLAG =4 --data is moved to Datawarehouse
    MINUS
    (SELECT THI.ID FROM TXN_HEADER_INTERFACE THI,ORDERS OS,ORDER_ITEMS OI
    WHERE THI.ID = OS.TXN_HDR_INFC_ID
    AND OS.ID = OI.ORDERS_ID
    OI.DW_STATUS_FLAG !=4);
    IF SQL%NOTFOUND
    THEN
    EXIT;
    END IF;
    FORALL i IN TXN_HDR_INFC_ID_ARRAY.FIRST..TXN_HDR_INFC_ID_ARRAY.LAST SAVE
    EXCEPTIONS
    DELETE FROM ORDER_ITEMS OI
    WHERE OI.ID IN (SELECT OI.ID FROM ORDER_ITEMS OI,ORDERS
    OS,TXN_HEADER_INTERFACE THI
    WHERE OS.ID = OI.ORDERS_ID
    AND OS.TXN_HDR_INFC_ID = THI.ID
    AND THI.ID = TXN_HDR_INFC_ID_ARRAY(i));
    FORALL i IN TXN_HDR_INFC_ID_ARRAY.FIRST..TXN_HDR_INFC_ID_ARRAY.LAST SAVE
    EXCEPTIONS
    DELETE FROM ORDERS OS
    WHERE OS.ID IN (SELECT OS.ID FROM ORDERS OS,TXN_HEADER_INTERFACE THI
    WHERE OS.TXN_HDR_INFC_ID = THI.ID
    AND THI.ID = TXN_HDR_INFC_ID_ARRAY(i));
    FORALL i IN TXN_HDR_INFC_ID_ARRAY.FIRST..TXN_HDR_INFC_ID_ARRAY.LAST SAVE
    EXCEPTIONS
    DELETE FROM TXN_HEADER_INTERFACE THI
    WHERE THI.ID = TXN_HDR_INFC_ID_ARRAY(i);
    COMMIT;
    DBMS_OUTPUT.PUT_LINE(TO_CHAR(SYSDATE, 'DD-MON-YY HH:MIPM')||':
    DELETE_CONFIRMED_DATA: INFO:DELETION SUCCESSFUL');
    EXCEPTION
    WHEN OTHERS THEN
    ERROR_COUNT := SQL%BULK_EXCEPTIONS.COUNT;
    DBMS_OUTPUT.PUT_LINE(TO_CHAR(SYSDATE, 'DD-MON-YY HH:MIPM')||':
    DELETE_CONFIRMED_DATA: ERROR:Number of errors is ' ||ERROR_COUNT);
    FOR indx IN 1..ERROR_COUNT LOOP
    DBMS_OUTPUT.PUT_LINE('Error ' || indx || 'occurred during
    '||'iteration'||SQL%BULK_EXCEPTIONS(indx).ERROR_INDEX);
    DBMS_OUTPUT.PUT_LINE('Error is '
    ||SQLERRM(-SQL%BULK_EXCEPTIONS(indx).ERROR_CODE));
    END LOOP;
    END DELETE_CONFIRMED_DATA;
    Any suggestion would be of great help.
    Thanks in advance
    Anu

    If you have one or two places in your code that need multiple exceptions, just do it with multiple catch statements. Unless you are trying to write the most compact Programming 101 homework program, inventing tricks to remove two lines of code is not good use of your time.
    If you have multiple catches all over your code it could be a code smell. You may have too much stuff happening inside one try statement. It becomes hard to know what method call throws one of those exceptions, and you end up handling an exception from some else piece of code than what you intended. E.g. you mention NumberFormatException -- only process one user input inside that try/catch so it is easy to see what error message is given if that particular input is gunk. The next step of processing goes inside its own try/catch.
    In my case, the ArrayIndexOutOfBoundsException and
    NumberFormatException should be handled by the same way.Why?
    I don't think I have ever seen an ArrayIndexOutOfBoundsException that didn't indicate a bug in the code. Instead of an AIOOBE perhaps there should be an if statement somewhere that prevents it, or the algorithm logic should prevent it automatically.

  • How to decide the limit in bulk collect clause

    Hi,
    we have got a pl/sql application which is performing mass DML including bulk insert,update and merge over millions of data.Now i am little bit confused in deciding the LIMIT in bulk collect clause.is there any way from which i can decide the optimal limit for my bulk collect clause.and i want to know what are the key factors that affects the limit in bulk collect.
    eargerly waiting for ur reply...
    thanx
    somy

    Hello,
    Check this example out and it might help you. All depends how much memory you want to allocate to do this job, you have to experiment to find optimal value (see memory consumption, speed of pl/sql block). There is no formula for finding optimal value as every system is configured differently, so once you have to see how is your oracle parameter (memory related ) configured and monitor system while this is running. I had used 500 for aroun 2.8 million rows.
    DECLARE
       TYPE array
       IS
          TABLE OF my_objects%ROWTYPE
             INDEX BY BINARY_INTEGER;
       data          array;
       errors        NUMBER;
       dml_errors exception;
       error_count   NUMBER := 0;
       PRAGMA EXCEPTION_INIT (dml_errors, -24381);
       CURSOR mycur
       IS
          SELECT *
          FROM t;
    BEGIN
       OPEN mycur;
       LOOP
          FETCH mycur BULK COLLECT INTO data LIMIT 100;
          BEGIN
             FORALL i IN 1 .. data.COUNT
             SAVE EXCEPTIONS
                INSERT INTO my_new_objects
                VALUES data (i);
          EXCEPTION
             WHEN dml_errors
             THEN
                errors        := sql%BULK_EXCEPTIONS.COUNT;
                error_count   := error_count + errors;
                FOR i IN 1 .. errors
                LOOP
                   DBMS_OUTPUT.put_line(   'Error occurred during iteration '
                                        || sql%BULK_EXCEPTIONS(i).ERROR_INDEX
                                        || ' Oracle error is '
                                        || sql%BULK_EXCEPTIONS(i).ERROR_CODE);
                END LOOP;
          END;
          EXIT WHEN c%NOTFOUND;
       END LOOP;
       CLOSE mycur;
       DBMS_OUTPUT.put_line (error_count || ' total errors');
    END;Regards
    OrionNet
    Edited by: OrionNet on Dec 17, 2008 12:55 AM

  • HELP!!! How to print out details in BULK COLLECT?

    I have a
    select line#, item, price ...
    BULK COLLECT into v_line_table
    from table_1, table_2
    where ....
    How can I do dbms_output.put_line from v_line_table, so I can see what value I got?
    Please help! Thank you

    doesn't seems to recognize the word "COLLECTION"
    dbms_output.put_line(COLLECTION.my_column);
    I aslo tried FOR LOOP, no luck
    FOR x IN 1 .. v_line_table.COUNT
    LOOP
    dbms_output.put_line('v_line_table.line_discount '|| v_line_table(x).line_discount); */
    END LOOP;
    please advise

  • How to install sccm client on bulk collections using push installation

    Unfortunately I did something and received the following description:-
    How to know/reproduce the following scenario by installing sccm client on bulk collections in SCCM 2012R2? 
    "User ***** requested that the CCRs will be generated for collection “All Windows Client Systems (P0100015), The SMS Provider did not generate CCRs for all the system resources in this collection.
    Possible cause: some system resources are not assigned to the current site, and you chose to insta
    Il clients only on system resources that are
    assigned to current site. 
    Another possible cause: Some system resources do not have Microsoft Windows NT operating system
    or above installed.
    Message ID: 30110"

    Ok. Some of your clients are not covered under any site assignment boundary, hence you are getting that error. Would recommend you to select "Install the client from a specified site" and select the Primary site. If your boundary groups for content
    are configured fine then the client will be installed from the appropriate site for each machine you are pushing the client to.
    -RG

  • How do I speed up this bulk collect

    Edited... Sorry for the wasted post...

    As soon as I posted this I figured out the problem so I removed the post. The problem was in the select section in the get_segment_length function and had nothing to do with the table() functions... After re-writing that this select actually works fast now...
          -- Join everything back together using the reduced segements tab.
          select sms.eval_rec(
            accd.accident_id,
            accd.accd_dte,
            accd.accd_catg,
            accd.accd_catg_description,
            accd.accd_rt_seq_num,
            accd.dmv_accd_clsf,
            sms.pa_pies_equations.get_segment_length(r_beg.rt_num, r_beg.rt_seq_num, r_end.rt_seq_num),
            r_beg.segment_region,
            r_beg.route_refmkr_id,
            r_end.route_refmkr_id,
            r_beg.refmkr,
            r_beg.rt_seq_num,
            r_end.refmkr,
            r_end.rt_seq_num,
            s.rt_num,
            p.construction_start_date,
            p.construction_end_date,
            p.investigation_id,
            p.maj_proj_num,
            p.proj_legacy_id,
            s.euac,
            s.est_severe_accident_reduction,
            s.est_total_accident_reduction,
            s.pseudo_segment_id)
          BULK COLLECT INTO v_final_tab
          from table(v_proj_tab) p, table(v_begin_route_tab) r_beg, table(v_end_route_tab) r_end, table(v_accd_tab) accd, table(v_segment_tab_reduced) s
          where ((p.investigation_id = s.investigation_id) or (p.investigation_id is null and s.investigation_id is null))
            and ((p.maj_proj_num     = s.maj_proj_num)     or (p.maj_proj_num     is null and s.maj_proj_num     is null))
            and ((p.proj_legacy_id   = s.proj_legacy_id)   or (p.proj_legacy_id   is null and s.proj_legacy_id   is null))
            and s.rt_num                        = r_beg.rt_num
            and s.begin_rt_seq_num              = r_beg.rt_seq_num
            and s.rt_num                        = r_end.rt_num
            and s.end_rt_seq_num                = r_end.rt_seq_num
            and s.rt_num                        = accd.rt_num
            and (accd.accd_rt_seq_num between r_beg.rt_seq_num and r_end.rt_seq_num or
                 accd.accd_rt_seq_num between r_end.rt_seq_num and r_beg.rt_seq_num);

  • How to use BULK COLLECT in oracle forms

    hi gurus,
    I am using oracle forms
    Forms [32 Bit] Version 10.1.2.0.2 (Production)
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - ProductionI wanna use bulk collect from database table lets say <employees>
    while working on database level with collections and records it's working very well for me, but when I try to use that technique on oracle forms it hits me error
    error 591 this feature is not supported in client side programmingI know I can use cursors to loop through the records of oracle tables ,
    but I'm convenient while using collections and arrays
    for example
    Set Serveroutput On
    Declare
          Type Rec_T Is Record (     
           Empid Number ,
           Empname Varchar2(100)
          Type V_R Is Table Of Rec_T Index By Binary_Integer;     
          V_Array V_R;
    Begin
       Select Employee_Id , First_Name
       Bulk Collect
       Into V_Array
          From Employees; 
       For Indx In V_Array.First..V_Array.Last Loop
       Dbms_Output.Put_Line('employees id '||V_Array(Indx).Empid ||'and the name is '||V_Array(Indx).Empname);
       End Loop;      
         End;I wanna use this same way on oracle forms , for certain purposes , please guide me how can I use ...
    thanks...

    For information, you can use and populate a collection within the Forms application without using the BULK COLLECT
    Francoisactually I want to work with arrays , index tables ,
    like
             record_type (variable , variable2);
             type type_name <record_type>  index by binary_integer
            type_variable type_name;
            and in main body of program
            select something
            bulk collect into type_variable
            from any_table;
           loop
                type_variable(indx).variable , type_variable(indx).variable2;
           end loop;
           this is very useful for my logic on which I am working
              like
              type_variable(indx).variable || type_variable(indx-1);
             if it's possible with cursors then how can I use cursor that can fullfill my this logic@Francois
    if it's possible then how can i populate without using bulk collect?
    thanks
    and for others replies: if I can use stored procedures please give me any example..
    thanks

  • USING IF IN FORALL AND BULK COLLECT

    Hi All,
    I wrote an program..I have doubt whether i can use if condition in FORALL INSERT OR BULK COLLECT? I can't go for 'for loop' ....Is there any way to to do validations in FORALL INSERT and BULK COLLECT like we do in 'for loop' ...
    create or replace
    PROCEDURE name AS
    CURSOR CUR_name IS
    SELECT OLD_name,NEW_name FROM DIRECTORY_LISTING_AUDIT;
    TYPE V_OLD_name IS TABLE OF DIRECTORY_LISTING_AUDIT.OLD_name%TYPE;
    Z_V_OLD_name V_OLD_name ;
    TYPE V_NEW_name IS TABLE OF DIRECTORY_LISTING_AUDIT.NEW_name%TYPE;
    Z_V_NEW_name V_NEW_name ;
    BEGIN
    OPEN CUR_name ;
    LOOP
    FETCH CUR_name BULK COLLECT INTO Z_V_OLD_name,Z_V_NEW_name;
    IF Z_V_NEW_name <> NULL THEN
    Z_V_OLD_name := Z_V_NEW_name ;
    Z_V_NEW_name := NULL;
    END IF;
    FORALL I IN Z_V_NEW_name.COUNT
    INSERT INTO TEMP_DIREC_AUDIT (OLD_name,NEW_name) VALUES (Z_V_OLD_name(I),Z_V_NEW_name(I));
    EXIT WHEN CUR_name%NOTFOUND;
    END LOOP;
    CLOSE CUR_name;
    END name;

    FORALL i IN v_tab.FIRST .. v_tab.LAST
             INSERT ALL
                WHEN v_tab (i) = 1
                THEN
                   INTO sen_temp
                        (col_num
                 VALUES (v_tab (i) + 5
                SELECT dummy
                  FROM DUAL;
          EXIT WHEN c1%NOTFOUND;this is the one u looking for i guess...

  • How to use BULK COLLECT in Oracle Forms 11g

    Forms is showing error that "Feature is not support in Client Side Program" when i am trying to impliment Bulk collect in Forms 11g.
    i need to load full data from DB to my form becuase using cursor is very slow....
    Is there any method/Work around to achieve this ....

    declare
    type arr is table of emp%rowtype ;
    lv_arr arr;
    begin
    select * bulk collect in to lv_arr from emp;
    /*written code here to process the data and write in to file*/
    end;Unless you are inserting/updating the data you are holding in the array into a database table I don't think there is much peformance gain in using bulk-collect in conjunction with writing a file. Bulk processing will increase performance by minimizing context switches from the SQL to the PL/SQL engine, nothing more, nothing less.
    In any case bulk processing is not available in forms, if you really need to make use of it you need to do it in a stored procedure.
    cheers

  • Query on bulk collect

    Hi
    I have the following PL/SQL code.
    type temp_atlanta is table of atlanta_operator%rowtype
    index by binary_integer;
    atlanta_1 temp_atlanta;
    begin
    select * bulk collect into atlanta_1 from atlanta_operator;
    forall k in 1..atlanta_1.count
    insert into pt_atlanta_operator values atlanta_1(k);
    end;
    Query :- I want to commit after every 1000 records are inserted. Please tell me how to put rowcount in bulk inserts as %rowcount is not working here .

    You would probably want to use the LIMIT clause in your BULK COLLECT, i.e.
    type temp_atlanta is table of atlanta_operator%rowtype
      index by binary_integer;
    atlanta_1 temp_atlanta;
    CURSOR c1 IS
      SELECT *
        FROM atlanta_operator;
    BEGIN
      OPEN c1;
      LOOP
        FETCH c1
          BULK COLLECT INTO atlanta_1
          LIMIT 1000;
        IF( temp_atlanta.count > 0 )
        THEN
          FORALL k IN 1..temp_atlanta.count
            INSERT INTO pt_atlanta_operator VALUES atlanta_1(k);
        END IF;
        EXIT WHEN c1%NOTFOUND;
      END LOOP;
    END;Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Bulk Collect Problem

    I have table Tab1 has 20 columns
    i have table tab2 has 10 columns , i want you uses the bulk collect insert in tab2 to tab 1 only selected columns from the tab1 .
    TYPE ARRAY IS TABLE OF tab2%ROWTYPE;
    l_tab_array ARRAY;
    BEGIN
    SELECT * BULK COLLECT INTO l_tab_array
    FROM tab1;
    FORALL x in l_tab_array.First..l_tab_array.Last
    INSERT INTO tab2(column1,column2 ) VALUES l_tab_array(x) ; --please tell me how to access the array column.
    END;
    i tried INSERT INTO tab2(column1) VALUES (l_tab_array(x).col1)
    10:21:07 AM 47/61 PLS-00436: implementation restriction: cannot reference fields of BULK In-BIND table of records
    10:21:07 AM 47/61 PLS-00382: expression is of wrong type
    10:21:07 AM 47/61 PL/SQL: ORA-22806: not an object or REF
    please give the insert statement with array .
    Regards
    ram
    Edited by: Mani on Feb 10, 2011 3:19 PM

    Yep - this is a right pain in older versions of Oracle.
    You need to have one associative array per column.
    Also see this article from Adrian Billington about alternatives:
    http://www.oracle-developer.net/display.php?id=410
    However, it may be that you're misusing collections etc when the best solutions is always a SQL single statement:
    INSERT
    INTO ...
    SELECT..
    Edited by: Dom Brooks on Feb 10, 2011 3:25 PM

  • Bulk Collect Limiting data problem

    Hi all,
    i am using a cursor for migrating data form one table to another.
    i say:
    fetch c_mycur bulk collect into r_myrow limit 10000;
    exit when c_mycur%notfound;
    forall i in r_myrow.first .. r_myrow.last
    insert into table2 values r_myrow(i);
    But there is a missout point that:
    Table1 has 400234 data but it copies 400000 to the table2.
    I want it to do full copy.How can i correct this???
    Thanks...

    Dear all..
    Sory i just want to share about bulk collect limiting problem, because i also get the same problem when using it. Actually before I just want to check the performance between bulk collect with explicit cursor and implicit cursor. below is my testing :
    SQL> ed
    Wrote file afiedt.buf
    1 DECLARE
    2 CURSOR c_server IS
    3 SELECT * FROM TRAN_DATA;
    4 TYPE transerver IS TABLE OF c_server%ROWTYPE;
    5 cur_server transerver;
    6 TYPE mytran IS TABLE OF TRAN_DATA%ROWTYPE;
    7 c_tran mytran;
    8 START_TIME NUMBER;
    9 END_TIME NUMBER;
    10 L_count NUMBER;
    11 BEGIN
    12 EXECUTE IMMEDIATE 'TRUNCATE TABLE TRAN_DATA_SERVERS';
    13 START_TIME := DBMS_UTILITY.GET_tIME;
    14 OPEN c_server;
    15 LOOP
    16 FETCH c_server BULK COLLECT INTO cur_server LIMIT 100;
    [b] 17 EXIT WHEN c_server%NOTFOUND;
    18 FORALL i IN cur_server.FIRST..cur_server.LAST
    19 INSERT INTO tran_data_servers VALUES cur_Server(i);
    20 END LOOP;
    21 CLOSE c_server;
    22 SELECT count(*) INTO l_count FROM tran_data_servers;
    23 DBMS_OUTPUT.PUT_LINE('row processing = '||L_cOUNT);
    24 END_TIME := DBMS_UTILITY.GET_tIME;
    25 DBMS_OUTPUT.PUT_LINE('TIME FOR CURSOR BULK FOR ALL = '||TO_CHAR(END_TIME-START_TIME));
    26 EXECUTE IMMEDIATE 'TRUNCATE TABLE array_TRAN_DATA';
    27 START_TIME := DBMS_UTILITY.GET_tIME;
    28 SELECT * BULK COLLECT INTO c_tran FROM TRAN_DATA;
    29 FORALL i IN c_tran.FIRST..c_tran.LAST
    30 INSERT INTO array_tran_data VALUES c_tran(i);
    31 END_TIME := DBMS_UTILITY.GET_tIME;
    32 L_count:= null;
    33 SELECT count(*) INTO l_count FROM array_tran_data;
    34 DBMS_OUTPUT.PUT_LINE('row processing = '||L_cOUNT);
    35 DBMS_OUTPUT.PUT_LINE('select into BULK FOR ALL = '||TO_CHAR(END_TIME-START_TIME));
    36* END;
    37 /
    row processing = 287400
    TIME FOR CURSOR BULK FOR ALL = 789
    row processing = 287417
    select into BULK FOR ALL = 811
    PL/SQL procedure successfully completed.
    SQL> ed
    Wrote file afiedt.buf
    1 DECLARE
    2 CURSOR c_server IS
    3 SELECT * FROM TRAN_DATA;
    4 TYPE transerver IS TABLE OF c_server%ROWTYPE;
    5 cur_server transerver;
    6 TYPE mytran IS TABLE OF TRAN_DATA%ROWTYPE;
    7 c_tran mytran;
    8 START_TIME NUMBER;
    9 END_TIME NUMBER;
    10 L_count NUMBER;
    11 BEGIN
    12 EXECUTE IMMEDIATE 'TRUNCATE TABLE TRAN_DATA_SERVERS';
    13 START_TIME := DBMS_UTILITY.GET_tIME;
    14 OPEN c_server;
    15 LOOP
    16 FETCH c_server BULK COLLECT INTO cur_server LIMIT 100;
    17 FORALL i IN cur_server.FIRST..cur_server.LAST
    18 INSERT INTO tran_data_servers VALUES cur_Server(i);
    [b]19 EXIT WHEN c_server%NOTFOUND;
    20 END LOOP;
    21 CLOSE c_server;
    22 SELECT count(*) INTO l_count FROM tran_data_servers;
    23 DBMS_OUTPUT.PUT_LINE('row processing = '||L_cOUNT);
    24 END_TIME := DBMS_UTILITY.GET_tIME;
    25 DBMS_OUTPUT.PUT_LINE('TIME FOR CURSOR BULK FOR ALL = '||TO_CHAR(END_TIME-START_TIME));
    26 EXECUTE IMMEDIATE 'TRUNCATE TABLE array_TRAN_DATA';
    27 START_TIME := DBMS_UTILITY.GET_tIME;
    28 SELECT * BULK COLLECT INTO c_tran FROM TRAN_DATA;
    29 FORALL i IN c_tran.FIRST..c_tran.LAST
    30 INSERT INTO array_tran_data VALUES c_tran(i);
    31 END_TIME := DBMS_UTILITY.GET_tIME;
    32 L_count:= null;
    33 SELECT count(*) INTO l_count FROM array_tran_data;
    34 DBMS_OUTPUT.PUT_LINE('row processing = '||L_cOUNT);
    35 DBMS_OUTPUT.PUT_LINE('select into BULK FOR ALL = '||TO_CHAR(END_TIME-START_TIME));
    36* END;
    SQL> /
    row processing = 287417
    TIME FOR CURSOR BULK FOR ALL = 558
    row processing = 287417
    select into BULK FOR ALL = 624
    PL/SQL procedure successfully completed.
    As you can see if we put the EXIT WHEN c_server%NOTFOUND; before the forall statement then not all the row will processing, but if we put EXIT WHEN c_server%NOTFOUND; after the forall statement it's will processing all rows. So maybe the solutions just put the EXIT WHEN c_server%NOTFOUND; after the forall statement. As you can see also there's the different bulk collect with implicit and explicit cursor, i think using explicit with limit will be more faster.
    Thank you
    Thanks

  • UNION operator with BULK COLLECT for a collection type

    Hi all,
    I created a table type as below:
    create or replace type coltest is table of number;
    Below are 3 PL/SQL blocks that populate data into variables of the above mentioned table type:
    BLOCK 1:
    DECLARE
    col1 coltest := coltest(1, 2, 3, 4, 5, 11);
    col2 coltest := coltest(6, 7, 8, 9, 10);
    col3 coltest := coltest();
    BEGIN
    SELECT * BULK COLLECT
    INTO col1
    FROM (SELECT *
    FROM TABLE(CAST(col1 AS coltest))
    UNION ALL
    SELECT * FROM TABLE(CAST(col2 AS coltest)));
    dbms_output.put_line('col1');
    dbms_output.put_line('col1.count: ' || col1.COUNT);
    FOR i IN 1 .. col1.COUNT
    LOOP
    dbms_output.put_line(col1(i));
    END LOOP;
    END;
    OUPUT:
    col1
    col1.count: 5
    6
    7
    8
    9
    10
    BLOCK 2:
    DECLARE
    col1 coltest := coltest(1, 2, 3, 4, 5, 11);
    col2 coltest := coltest(6, 7, 8, 9, 10);
    col3 coltest := coltest();
    BEGIN
    SELECT * BULK COLLECT
    INTO col2
    FROM (SELECT *
    FROM TABLE(CAST(col1 AS coltest))
    UNION ALL
    SELECT * FROM TABLE(CAST(col2 AS coltest)));
    dbms_output.put_line('col2');
    dbms_output.put_line('col2.count: ' || col2.COUNT);
    FOR i IN 1 .. col2.COUNT
    LOOP
    dbms_output.put_line(col2(i));
    END LOOP;
    END;
    OUTPUT:
    col2
    col2.count: 6
    1
    2
    3
    4
    5
    11
    BLOCK 3:
    DECLARE
    col1 coltest := coltest(1, 2, 3, 4, 5, 11);
    col2 coltest := coltest(6, 7, 8, 9, 10);
    col3 coltest := coltest();
    BEGIN
    SELECT * BULK COLLECT
    INTO col3
    FROM (SELECT *
    FROM TABLE(CAST(col1 AS coltest))
    UNION ALL
    SELECT * FROM TABLE(CAST(col2 AS coltest)));
    dbms_output.put_line('col3');
    dbms_output.put_line('col3.count: ' || col3.COUNT);
    FOR i IN 1 .. col3.COUNT
    LOOP
    dbms_output.put_line(col3(i));
    END LOOP;
    END;
    OUTPUT:
    col3
    col3.count: 11
    1
    2
    3
    4
    5
    11
    6
    7
    8
    9
    10
    Can anyone please explain the output of BLOCK 1 and 2? Why doesn't bulk collect into col1 and col2 return 11 as count?

    Consider the following code from your block.
    select *
      bulk collect into col1
      from (
             select *
               from table(cast(col1 as coltest))
              union
                all
             select *
               from table(cast(col2 as coltest))
           ); Now my assumption would be like this.
    PL/SQL engine would recognize the SQL part and will be sending it to SQL Engine for processing. Before doing that it will try to initialize the SQL collection variable COL1. Now when SQL Engine process the SELECT, COL1 would be empty already. And thats the reason you don't get the as 5 and not 11.

Maybe you are looking for

  • Domain Object and Service oriented pattern

    We have J2EE based application with following components, we are facing some issues with existing system. Current System : We have J2EE based application. The following is the flow. Client Layer [including JSP, Struts ] action classes  Delegates 

  • Loading Images into Applets

    I've been having problems loading an image into an Applet. I've found that when the getImage() call is put into the init() method it loads the image fine, also implementing an imageUpdate call. However, now I'm trying to expand on this by putting it

  • Looking for a Powershell Script which can put the scom servers in maintenance mode

    Looking for a Powershell Script which can put the scom servers in maintenance mode so that SCOM should not send an alert during planned task. Rahul

  • Window 8.1 and secureboot

    Hi I build my first computer 2months ago using an MSI z87G343 and also a GTX760 twin Frozr 2g and everything went super easy with window8 set-up and got the quick boot option enabled and stuff.  I just did the update to from window 8 to 8.1 and got t

  • How to combine files like the iTunes store does?

    When you buy a Movie or TV Show on iTunes you recieve two versions of it, but it appears as just one file on iTunes. I was just wondering if its possible to do that manually to your own videos that you import into iTunes.