Problem with bulk collect

HII All,
I am facing a problem with in bulk collect unable to identify where my code is wrong. When I try to run the code below its getting hanged and thus leading to the end of the session. Please help me.

Here I am providing examples of data.

CREATE TABLE R_DUMMY
   (FA_FAC_OS NUMBER(34,14), 
  FAC_ID VARCHAR2(10) NOT NULL, 
  SYSTEM_ID NUMBER(6,0) NOT NULL, 
  WRKNG_CPY VARCHAR2(1) NOT NULL, 
  CA_ID VARCHAR2(16) NOT NULL, 
  FA_PRNT_FAC_ID VARCHAR2(10)
   );

insert into r_dummy (FA_FAC_OS, FAC_ID, SYSTEM_ID, WRKNG_CPY, CA_ID, FA_PRNT_FAC_ID)
values (10000.00000000000000, 'FA000001', 1, 'C', 'CA2001/11/0002', '');

insert into r_dummy (FA_FAC_OS, FAC_ID, SYSTEM_ID, WRKNG_CPY, CA_ID, FA_PRNT_FAC_ID)
values (500.00000000000000, 'FA000005', 1, 'C', 'CA2001/11/0002', '');

insert into r_dummy (FA_FAC_OS, FAC_ID, SYSTEM_ID, WRKNG_CPY, CA_ID, FA_PRNT_FAC_ID)
values (-500.00000000000000, 'FA000008', 1, 'C', 'CA2001/11/0002', '');

insert into r_dummy (FA_FAC_OS, FAC_ID, SYSTEM_ID, WRKNG_CPY, CA_ID, FA_PRNT_FAC_ID)
values (600.00000000000000, 'FA000013', 1, 'C', 'CA2001/11/0002', '');

insert into r_dummy (FA_FAC_OS, FAC_ID, SYSTEM_ID, WRKNG_CPY, CA_ID, FA_PRNT_FAC_ID)
values (600.00000000000000, 'FA000018', 1, 'C', 'CA2001/11/0002', '');

insert into r_dummy (FA_FAC_OS, FAC_ID, SYSTEM_ID, WRKNG_CPY, CA_ID, FA_PRNT_FAC_ID)
values (700.00000000000000, 'FA000020', 1, 'C', 'CA2001/11/0002', '');

insert into r_dummy (FA_FAC_OS, FAC_ID, SYSTEM_ID, WRKNG_CPY, CA_ID, FA_PRNT_FAC_ID)
values (1200.00000000000000, 'FA000022', 1, 'C', 'CA2001/11/0002', '');

CREATE TABLE R_DUMMY_1
   (FA_FAC_OS NUMBER(34,14), 
     FAC_ID VARCHAR2(10) NOT NULL,
     SYSTEM_ID NUMBER(6,0) NOT NULL,
     VER_NUM NUMBER(4,2) NOT NULL
   );

insert into r_dummy_1 (FA_FAC_OS, FAC_ID, SYSTEM_ID, VER_NUM)
values (10000.00000000000000, 'FA000001', 1, 3.00);

insert into r_dummy_1 (FA_FAC_OS, FAC_ID, SYSTEM_ID, VER_NUM)
values (10000.00000000000000, 'FA000001', 1, 2.00);

insert into r_dummy_1 (FA_FAC_OS, FAC_ID, SYSTEM_ID, VER_NUM)
values (10000.00000000000000, 'FA000001', 1, 1.00);

insert into r_dummy_1 (FA_FAC_OS, FAC_ID, SYSTEM_ID, VER_NUM)
values (500.00000000000000, 'FA000005', 1, 3.00);

insert into r_dummy_1 (FA_FAC_OS, FAC_ID, SYSTEM_ID, VER_NUM)
values (500.00000000000000, 'FA000005', 1, 2.00);

insert into r_dummy_1 (FA_FAC_OS, FAC_ID, SYSTEM_ID, VER_NUM)
values (500.00000000000000, 'FA000005', 1, 1.00);

insert into r_dummy_1 (FA_FAC_OS, FAC_ID, SYSTEM_ID, VER_NUM)
values (-500.00000000000000, 'FA000008', 1, 3.00);

insert into r_dummy_1 (FA_FAC_OS, FAC_ID, SYSTEM_ID, VER_NUM)
values (-500.00000000000000, 'FA000008', 1, 2.00);
And my block of pl sql
Set serveroutput on;

Declare
          vPkgCaId          r_dummy.ca_id%type          := 'CA2001/11/0002';
          vPkgSystemId     r_dummy.system_id%type     := 1;
          vPkgWrkFlg          r_dummy.WRKNG_CPY%type     :=  'C';

          

          
          type t_type is object
                                   (
                                   v_FA_FAC_OS     r_dummy.FA_FAC_OS%type,
                                   v_FAC_ID     r_dummy.FAC_ID%type,
                                   v_SYSTEM_ID     r_dummy.SYSTEM_ID%type,
                                   v_ver_num     r_dummy_1.ver_num%type
                                   );

          type t_col_tbl is table of t_type index by binary_integer;
          
          l_col_tbl     t_col_tbl;
          
          
          
          
          
          --fac_id,system_id,ver_num is composite primary key for CP_CA_FAC_VER
Begin
          
                    SELECT     fac.FA_FAC_OS,fac.FAC_ID,fac.SYSTEM_ID,ver.ver_num
                    bulk collect into l_col_tbl
                    FROM     r_dummy fac,r_dummy_1 ver
                    WHERE     fac.fac_id = ver.fac_id
                    and fac.system_id = ver.system_id
                    and fac.CA_ID = vPkgCaId
                    AND fac.SYSTEM_ID = vPkgSystemId
                    AND fac.WRKNG_CPY = vPkgWrkFlg
                    START WITH fac.CA_ID = vPkgCaId
                              AND fac.SYSTEM_ID = vPkgSystemId
                              AND fac.WRKNG_CPY = vPkgWrkFlg AND fac.FA_PRNT_FAC_ID IS NULL
                    CONNECT BY PRIOR fac.FAC_ID = fac.FA_PRNT_FAC_ID
                              AND fac.SYSTEM_ID = vPkgSystemId
                              AND fac.WRKNG_CPY = vPkgWrkFlg;
                    
          
          forall i in 1..l_col_tbl.count

               
               update     r_dummy_1 ver
               set          ver.FA_FAC_OS           = l_col_tbl(i).v_FA_FAC_OS
               where     fac_id                    = l_col_tbl(i).v_FAC_ID
                         and system_id          = l_col_tbl(i).v_system_id
                         and ver_num               = l_col_tbl(i).v_ver_num
                         ;
          

          Commit;

End;
/
Please help me. I was able to do to help collect cursor instead in bulk, but think that bulk collect will result in better performance. Please suggest if my code needs no changes.


Concerning
Rambeau

I'd rather do it right SQL which is much faster that COLLECT in BULK

 UPDATE r_dummy_1 ver
    SET ver.FA_FAC_OS =
        (
          SELECT fa_fac_os
            FROM (
                    SELECT fac.FA_FAC_OS,fac.FAC_ID,fac.SYSTEM_ID,ver.ver_num
                      FROM r_dummy fac,r_dummy_1 ver
                     WHERE fac.fac_id = ver.fac_id
                       and fac.system_id = ver.system_id
                       and fac.CA_ID = vPkgCaId
                       AND fac.SYSTEM_ID = vPkgSystemId
                       AND fac.WRKNG_CPY = vPkgWrkFlg
                     START WITH fac.CA_ID = vPkgCaId
                       AND fac.SYSTEM_ID = vPkgSystemId
                       AND fac.WRKNG_CPY = vPkgWrkFlg
                       AND fac.FA_PRNT_FAC_ID IS NULL
                   CONNECT BY PRIOR fac.FAC_ID = fac.FA_PRNT_FAC_ID
                       AND fac.SYSTEM_ID = vPkgSystemId
                       AND fac.WRKNG_CPY = vPkgWrkFlg
                 ) t
           WHERE t.fac_id = ver.fac_id
             AND t.system_id = ver.system_id
             AND t.ver_num = ver.ver_num
        )
  WHERE EXISTS
        (
          SELECT fa_fac_os
            FROM (
                    SELECT fac.FA_FAC_OS,fac.FAC_ID,fac.SYSTEM_ID,ver.ver_num
                      FROM r_dummy fac,r_dummy_1 ver
                     WHERE fac.fac_id = ver.fac_id
                       and fac.system_id = ver.system_id
                       and fac.CA_ID = vPkgCaId
                       AND fac.SYSTEM_ID = vPkgSystemId
                       AND fac.WRKNG_CPY = vPkgWrkFlg
                     START WITH fac.CA_ID = vPkgCaId
                       AND fac.SYSTEM_ID = vPkgSystemId
                       AND fac.WRKNG_CPY = vPkgWrkFlg
                       AND fac.FA_PRNT_FAC_ID IS NULL
                   CONNECT BY PRIOR fac.FAC_ID = fac.FA_PRNT_FAC_ID
                       AND fac.SYSTEM_ID = vPkgSystemId
                       AND fac.WRKNG_CPY = vPkgWrkFlg
                 ) t
           WHERE t.fac_id = ver.fac_id
             AND t.system_id = ver.system_id
             AND t.ver_num = ver.ver_num
        )      

Tags: Database

Similar Questions

  • Problem with BULK collect and variable of Table type

    Hi all
    I defined a record type and then set an index - by table of this record type and in bulk has collected the data as shown in the code below. All this was done in an anonymous block.

    Then when I tried to set the record as an object type and not the above activities type, I got the below error:

    ORA-06550: line 34, column 6:
    PL/SQL: ORA-00947: not enough values
    ORA-06550: line 31, column 4:
    PL/SQL: SQL statement ignored

    Could you help me get the result of the first scenario with record type defined as an object?
    /* Formatted on 2009/08/03 17:01 (Formatter Plus v4.8.8) */
    DECLARE
       TYPE obj_attrib IS TABLE OF num_char_object_1
          INDEX BY PLS_INTEGER;
    
       obj_var   obj_attrib;
    
       TYPE num_char_record IS RECORD (
          char_attrib   VARCHAR2 (100),
          num_attrib    NUMBER
       );
    
       TYPE rec_attrib IS TABLE OF num_char_record
          INDEX BY PLS_INTEGER;
    
       rec_var   rec_attrib;
    BEGIN
       SELECT first_name,
              employee_id
       BULK COLLECT INTO rec_var
         FROM employees
        WHERE ROWNUM <= 10;
    
       FOR iloop IN rec_var.FIRST .. rec_var.LAST
       LOOP
          DBMS_OUTPUT.put_line (
             'Loop.' || iloop || rec_var (iloop).char_attrib || '###'
             || rec_var (iloop).num_attrib
          );
       END LOOP;
    
       SELECT first_name,
              employee_id
       BULK COLLECT INTO obj_var
         FROM employees
        WHERE ROWNUM <= 10;
    END;
    Here's the code for num_char_object_1
    CREATE OR REPLACE TYPE NUM_CHAR_OBJECt_1 IS OBJECT (
       char_attrib   VARCHAR2 (100),
       num_attrib    NUMBER
    );

    Welcome to the forum!

    You should be collecting objects in bulk, something like

    SELECT NUM_CHAR_OBJECt_1  (first_name,
              employee_id)
       BULK COLLECT INTO obj_var
         FROM emp
        WHERE ROWNUM <= 10;
    
  • Problem with cursor collection

    Hello


    Oracle srvr: 10.2.0.1.0


    When I execute the following
    declare
    type i_values is varray(20000) of employee_details%rowtype;
    s_values i_values :=i_values();
    cursor c1 is select * from employee_details where rownum < 11;
    begin
    loop
    begin
    fetch c1  into s_values  ;
    s_values.extend;
    exit when c1%NOTFOUND;
    exception
    when  invalid_cursor then
    dbms_output.put_line('Cursor invalid');
    when others then
    dbms_output.put_line('Others');
    end ;
    end loop;
    for i in 1 .. s_values.count loop
    dbms_output.put_line(s_values(i).eid);
    end loop;
    end;
    /
    I get the error as
    ERROR at line 8:
    ORA-06550: line 8, column 16:
    PLS-00597: expression 'S_VALUES' in the INTO list is of wrong type
    ORA-06550: line 8, column 1:
    PL/SQL: SQL Statement ignored
    Instead, when I run slider as bulk collect his execution but goes to an infinite loop

    Help, please

    As Justin has shown, that you want to use BULK collect if you extract the data in a collection.

    for example

    SQL> set serverout on
    SQL> ed
    Wrote file afiedt.buf
    
      1  declare
      2    type t_emps is table of emp%rowtype;
      3    v_emps t_emps;
      4    cursor c1 is
      5      select *
      6      from emp
      7      where rownum <= 10;
      8  begin
      9    open c1;
     10    fetch c1 bulk collect into v_emps;
     11    close c1;
     12    for i in 1 .. v_emps.count
     13    loop
     14      dbms_output.put_line(v_emps(i).empno||' - '||v_emps(i).ename);
     15    end loop;
     16* end;
    SQL> /
    7369 - SMITH
    7499 - ALLEN
    7521 - WARD
    7566 - JONES
    7654 - MARTIN
    7698 - BLAKE
    7782 - CLARK
    7788 - SCOTT
    7839 - KING
    7844 - TURNER
    
    PL/SQL procedure successfully completed.
    
    SQL>
    

    If your code is stuck in an infinite loop, you probably left the construction of LOOP in your code. That is not necessary with a big collection, unless you limit the number of rows read and must treat in pieces of defined size.

    If you are planning on extracting data to a load of INSERT statements then consider as being of bad practice.

    You would be better to export the data to a flat file (CSV) and having the receiver of database uses an external table (or SQL * Loader) If you need to load the data back in. A lot of insert statements will be slow.

    If you want to export the data to a flat file, you can use something like:

    As user sys:

    CREATE OR REPLACE DIRECTORY TEST_DIR AS '\tmp\myfiles'
    /
    GRANT READ, WRITE ON DIRECTORY TEST_DIR TO myuser
    /
    

    As myuser:

    CREATE OR REPLACE PROCEDURE run_query(p_sql IN VARCHAR2
                                         ,p_dir IN VARCHAR2
                                         ,p_header_file IN VARCHAR2
                                         ,p_data_file IN VARCHAR2 := NULL) IS
      v_finaltxt  VARCHAR2(4000);
      v_v_val     VARCHAR2(4000);
      v_n_val     NUMBER;
      v_d_val     DATE;
      v_ret       NUMBER;
      c           NUMBER;
      d           NUMBER;
      col_cnt     INTEGER;
      f           BOOLEAN;
      rec_tab     DBMS_SQL.DESC_TAB;
      col_num     NUMBER;
      v_fh        UTL_FILE.FILE_TYPE;
      v_samefile  BOOLEAN := (NVL(p_data_file,p_header_file) = p_header_file);
    BEGIN
      c := DBMS_SQL.OPEN_CURSOR;
      DBMS_SQL.PARSE(c, p_sql, DBMS_SQL.NATIVE);
      d := DBMS_SQL.EXECUTE(c);
      DBMS_SQL.DESCRIBE_COLUMNS(c, col_cnt, rec_tab);
      FOR j in 1..col_cnt
      LOOP
        CASE rec_tab(j).col_type
          WHEN 1 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);
          WHEN 2 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_n_val);
          WHEN 12 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_d_val);
        ELSE
          DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);
        END CASE;
      END LOOP;
      -- This part outputs the HEADER
      v_fh := UTL_FILE.FOPEN(upper(p_dir),p_header_file,'w',32767);
      FOR j in 1..col_cnt
      LOOP
        v_finaltxt := ltrim(v_finaltxt||','||lower(rec_tab(j).col_name),',');
      END LOOP;
      --  DBMS_OUTPUT.PUT_LINE(v_finaltxt);
      UTL_FILE.PUT_LINE(v_fh, v_finaltxt);
      IF NOT v_samefile THEN
        UTL_FILE.FCLOSE(v_fh);
      END IF;
      --
      -- This part outputs the DATA
      IF NOT v_samefile THEN
        v_fh := UTL_FILE.FOPEN(upper(p_dir),p_data_file,'w',32767);
      END IF;
      LOOP
        v_ret := DBMS_SQL.FETCH_ROWS(c);
        EXIT WHEN v_ret = 0;
        v_finaltxt := NULL;
        FOR j in 1..col_cnt
        LOOP
          CASE rec_tab(j).col_type
            WHEN 1 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_v_val);
                        v_finaltxt := ltrim(v_finaltxt||',"'||v_v_val||'"',',');
            WHEN 2 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_n_val);
                        v_finaltxt := ltrim(v_finaltxt||','||v_n_val,',');
            WHEN 12 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_d_val);
                        v_finaltxt := ltrim(v_finaltxt||','||to_char(v_d_val,'DD/MM/YYYY HH24:MI:SS'),',');
          ELSE
            v_finaltxt := ltrim(v_finaltxt||',"'||v_v_val||'"',',');
          END CASE;
        END LOOP;
      --  DBMS_OUTPUT.PUT_LINE(v_finaltxt);
        UTL_FILE.PUT_LINE(v_fh, v_finaltxt);
      END LOOP;
      UTL_FILE.FCLOSE(v_fh);
      DBMS_SQL.CLOSE_CURSOR(c);
    END;
    

    This allows the header line and the data to write into files separate if necessary.

    for example

    SQL> exec run_query('select * from emp','TEST_DIR','output.txt');
    
    PL/SQL procedure successfully completed.
    

    Output.txt file contains:

    empno,ename,job,mgr,hiredate,sal,comm,deptno
    7369,"SMITH","CLERK",7902,17/12/1980 00:00:00,800,,20
    7499,"ALLEN","SALESMAN",7698,20/02/1981 00:00:00,1600,300,30
    7521,"WARD","SALESMAN",7698,22/02/1981 00:00:00,1250,500,30
    7566,"JONES","MANAGER",7839,02/04/1981 00:00:00,2975,,20
    7654,"MARTIN","SALESMAN",7698,28/09/1981 00:00:00,1250,1400,30
    7698,"BLAKE","MANAGER",7839,01/05/1981 00:00:00,2850,,30
    7782,"CLARK","MANAGER",7839,09/06/1981 00:00:00,2450,,10
    7788,"SCOTT","ANALYST",7566,19/04/1987 00:00:00,3000,,20
    7839,"KING","PRESIDENT",,17/11/1981 00:00:00,5000,,10
    7844,"TURNER","SALESMAN",7698,08/09/1981 00:00:00,1500,0,30
    7876,"ADAMS","CLERK",7788,23/05/1987 00:00:00,1100,,20
    7900,"JAMES","CLERK",7698,03/12/1981 00:00:00,950,,30
    7902,"FORD","ANALYST",7566,03/12/1981 00:00:00,3000,,20
    7934,"MILLER","CLERK",7782,23/01/1982 00:00:00,1300,,10
    

    The procedure allows for the header and the data to separate files if necessary. Just by specifying the file name "header" will put the header and the data in a single file.

    Adapt to the exit of styles and different types of data are needed.

  • problem with the collection and refcursor

    I have the 'ServerDisconnect2' function below. It should return as 'ref_cursor' on the parameter that is a data container of deleted rows slider, Java developers insist on using this type of data/collection. I don't know how to code to return the values of ID removed as 'ref_cursor '. See commented "open pDeleteList" - sentence, it is commented as does not compile.
    CREATE OR REPLACE PACKAGE oe_ctx AS
      TYPE gIntegerTable IS TABLE OF INTEGER INDEX BY BINARY_INTEGER;
      TYPE cursor_type IS REF CURSOR;
    ....
    
      PROCEDURE ServerDisconnect2(pCasinoCode NUMERIC, pCasinoServerCode NUMERIC, pChannelServerCode CurrentLogins.ChannelServerCode%TYPE, pDeleteList OUT cursor_type) 
      IS
        vDeleteList oe_ctx.gIntegerTable;
      BEGIN
        DELETE FROM
        (
           SELECT cl.* FROM CurrentLogins cl, Accounts a
           WHERE cl.CasinoCode = pCasinoCode
           AND cl.CasinoServerCode = pCasinoServerCode
           AND cl.ChannelServerCode = pChannelServerCode
           AND cl.Code = a.code
           AND a.Type = 'lplayer'
           ORDER BY a.code
        ) RETURNING Code
          BULK COLLECT INTO vDeleteList;
          
    /*    OPEN pDeleteList FOR
          SELECT * FROM TABLE(vDeleteList);*/
          
        COMMIT;
      END ServerDisconnect2;
    Is it possible to convert the variable 'vDeleteList' in ref_cursor?
    So my only solution would be to open the ref_cursor BEFORE delete-clause with the same query delete clause has. But I'm afraid that then after opening the instant cursor after a milliseconds the deletion clause removes different lines and the procedure would be data incorrect in pDeleteList.

    Published by: CharlesRoos on August 26, 2010 06:10

    You need a collection of sql (created with CREATE TYPE...):

    I'll use the predefined collection sys.odcivarchar2list demonstation purposes:

    SQL> var cur refcursor
    
    SQL> declare
       ret_coll       sys.odcivarchar2list;
    begin
       delete from emp
         returning ename
              bulk collect into ret_coll;
    
       open :cur for select * from table (ret_coll);
    end;
    /
    PL/SQL procedure successfully completed.
    
    SQL> print
    
    COLUMN_VALUE
    -----------------------------------------------------------------------------------------------------------------------------
    SMITH
    ALLEN
    WARD
    JONES
    MARTIN
    BLAKE
    CLARK
    SCOTT
    KING
    TURNER
    ADAMS
    JAMES
    FORD
    MILLER                                                                                                                       
    
    14 rows selected.
    
  • Potential problems with bulk assigned DN ranges

    Nobody knows possible problems with loading up to say unassigned 100 DN at the Complutense University of MADRID (8,6) with all the parameters number of directory but not assigned to a device?

    The end of the game here is that we have a few 100 DIDs that are reserved for different reasons (diff ILA or for a client) that we loaded in the system, so they are reserved and no one is going to try and use them (the idea being someone will add a DID this description will fill and they know they need to enter a different DID).

    I can even send to the unit, but don't think it's important because they are all NEW DIDs that were never sold or announced.

    Our team of engineers seems to think that this will cause a problem such as call manager will be under heavy load constantly trying to figure out what devices attached to these DNs unassigned.  I say no because they have never been assigned to a device are are essentially a placeholder.

    This would cause a problem?

    If so - how guys do you manage your DIDs unused in call manager - it seems terribly archaic to manage a spreadsheet with unused DID we rely on the entire team through the world to update when they make changes when we have essentially a database (Manager call) here to do it for us!

    Thoughts?

    This will not cause any problems and can be performed without risk. In addition you can make the inactive DNs if you prefer.

    Chris

  • UNION operator with BULK COLLECT for one type of collection

    Hi all

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

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


    BLOCK 1:

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

    BEGIN

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

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

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

    END;

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



    BLOCK 2:

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

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

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

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

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

    BLOCK 3:

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

    BEGIN

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

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

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


    OUTPUT:

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

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

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

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

  • Problem with the Collection

    I have problems of filling of a collection.
    I created my collection on page load of the Page 7 for help
    BEGIN
    
    apex_collection.create_or_truncate_collection
      (p_collection_name => 'PEOPLE');
    
    END;
    The user then clicks on the "Copy" button that brings them to the Page 13.
    That's where I'm trying to complete my collection, by clicking on the link add to the report of the population.
    for x in (select * from gus_people_2 where id = :P13_ID)
    loop
      apex_collection.add_member(p_collection_name => 'PEOPLE', 
        p_c001 => x.id,
        p_c002 => x.rank,
        p_c003 => x.first_name,
        p_c004 => x.surname,
        p_c005 => x.dob,
        p_c006 => x.job,
        p_c007 => x.disp_seq);
    end loop;
    Once added, the Member of the collection should appear in the report of the full Collection.
    select c001, c002, c003, c004, c005, c006, c007, 'Remove' remove
    from apex_collections
    where collection_name = 'PEOPLE'
    I use Apex 4.1 on the Oracle website

    http://Apex.Oracle.com/pls/Apex/f?p=4550:1:0:

    Workspace: GUSCRIGHTON
    Username: ANGUS. [email protected]
    Password: terminator

    Application name: EXCEL_UPDATE_TEST

    Same username and password as described above.

    It's probably something really obvious, but I can't place it today.

    Any help appreciated.

    Gus

    Hi gUS,.
    Now, run your page, it will work.
    Thank you
    Loga

    Add the collection process
    Ask = exp1
    'ADD' - removed single quotes

    Remove the collection process

    Ask = exp1

    DEL - I gave this string.
    You will add later with link or a button.

    Published by: Logaa on May 18, 2012 06:04

  • ADF TUTORIAL: PROBLEMS WITH "export Collection Action Listener.

    Hi all

    environment:
    Windows xp
    jedev 11.1.1.3.0
    Firefox 3.6.13

    Tutorial: develop Ajax with JSF-based User Interfaces: An Introduction to ADF Faces Rich Client components
    URL: http://st-curriculum.oracle.com/obe/jdev/obe11jdev/ps1/adf_richclient/adfrichclient.htm

    mainstep: "work with menus.
    step: number 5 "add a listener for collection action.

    until the step "work with menus" everthing works fine. After that I added the earpiece of the collection action and saved my work, the webapplication does not open. I only see a blank page and no error message.
    When I delete the action listener works just fine again.

    How can I solve this problem? Thank you to everyone.

    Best regards
    Gunnar

    You can paste the code of the page where you added the listener to action?
    Make sure it is added within the menu option.

  • problem with a collection of table

    Hello!

    I work with Flex/Java RemoteObject.

    I have been following in Java

    public class IdAndName {}

    private String userId;
    private String userName;

    }

    and the equivalent in Flex

    public class IdAndName {}
    private var _userId:String;
    private var _userName:String;

    }

    I call a Java method that returns a list < IdAndName >. I get the list in flex in the following way:

    var list:ArrayCollection = ArrayCollection (event.result);

    If the var list list of the IdAndName.

    My Question is...:

    How can I get a collection ArrayCollection in Flex with the user ID (only them and not the username?)

    Thank you

    How do you list? you can fix your list in java or rewrite your ArrayCollection in flex like this collection:

    var list:ArrayCollection = ArrayCollection (event.result);

    var fitness sale: collection ArrayCollection = new ArrayCollection();

    for (var i: int = 0; i

    reList.addItem ((list.getItemAt (i) as array) [0]);     If the user ID is initially

    }

    Tell me if it does not help

  • Problem with the collection xmltype column - tags endangered

    Hello

    Apex 4.0, I have a traditional relationship with this query:
    SELECT c.collection_name,
           c.seq_id,
           c.c001,
           c.c002,
           c.xmltype001.getclobval() xmltype001
    FROM   apex_collections c
    The xmltype001 column is set to display text (special escape characters). What I see on the page of this something column is:
    <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
     <env:Header/>
     <env:Body>
     <m:tag1 xmlns:m="http://cosservices/COSServices.wsdl">
     <result xmlns:typ="http://cosservices/COSServices.wsdl/types/">
     <typ:tag2>
     <typ:subdepartmentCode>AUTO</typ:subdepartmentCode>
     <typ:subdepartmentName>Automotive</typ:subdepartmentName>
     <typ:itemNumber>0000610</typ:itemNumber>
    ...
    This column is filled by calling a web service using this package Apex web service utility, and this is the content for this column. However, when I export to CSV, what I see in the text file is the following:
      
      
        
          
            
              
              AUTO
              Automotive
         0000610
    ...
    In case you missed it: all tags have disappeared and that the actual data remained. If I change the type of column to Column Standard in the report, the same thing is happening on the page.

    My findings to date are:
    -Tags are present in the column, as it is sort of the column display in text type is smart enough to display the data correctly.
    -It seems that this has something to do with the character encoding, but I don't know how to fix it. I tried to use the convert() function but no luck.

    Any ideas?

    Thank you
    Luis

    Hi Luis,.

    It is not something as simple that the attribute "Strip HTML" report, is it?
    (ie - change no.)

    Scott

  • Problem with a collection

    I've defined in a package:

    TYPE TIPO_TABLA_CTRL_SIT IS TABLE OF THE IGIC_DECE_400_CTRL_SIT % ROWTYPE INDEX BY PLS_INTEGER;

    TABLA_CTRL_SIT TIPO_TABLA_CTRL_SIT;


    And in a feature...

    function COUNT_CTRL_SIT (p_TABLA_CTRL_SIT IN TIPO_TABLA_CTRL_SIT) RETURN NUMBER IS
    v_reg IGIC_DECE_400_CTRL_SIT % ROWTYPE;

    Start

    -Inicializacion THE DECLARACION REAL SITUATIONS
    v_reg: = p_TABLA_CTRL_SIT.first;

    END;

    Why the following error occurred when compiling?

    "Error: PLS 00382: el type of the expression are no correcto.

    Translation:

    "Error: PLS-00382: wrong type in the expression.

    Why I can't get the first item in the collection?

    Thanks in advance.

    Published by: pacoKAS on Apr / 02/2011 12:24

    Hello

    FIRST returns the index number of the first (smaller) of your collection, in this case a PLS_INTEGER.

    So I think that you need

    v_reg:= p_TABLA_CTRL_SIT(p_TABLA_CTRL_SIT.first);
    

    Concerning
    Peter

  • Problem with a collection empty

    When a process is running

    BECAUSE me IN g_tabla_situacion. FIRST... g_tabla_situacion. LAST
    LOOP
    .....
    END LOOP;

    and g_tabla_situacion contains no items, ORACLE returns a

    "* - 6502:ORA - 06502: PL/SQL: digital error or value."

    How can I avoid this problem?

    Now, I am doing...

    IF (g_tabla_situacion. COUNT > 0) THEN

    BECAUSE me IN g_tabla_situacion. FIRST... g_tabla_situacion. LAST
    LOOP
    .....
    END LOOP;

    END IF;

    but he does not seem the best solution...


    Thank you.

    Published by: pacoKAS on February 19, 2010 0:34

    Hello

    There is an article about this issue in Oracle magazine that presents different approaches and the advantages and disadvantages:
    http://HTMLDB.Oracle.com/pls/OTN/f?p=2853:4:no:P4_QA_ID:16762

    Concerning
    Marcus

  • Fetch Bulk collect Insert error

    CREATE OR REPLACE PROCEDURE bulk_collect_limit (StartRowOptional in NUMBER, EndRowOptional number, fetchsize in NUMBER)

    IS

    SID TYPE TABLE IS NUMBER;

    Screated_date TYPE IS an ARRAY OF DATE;

    Slookup_id TYPE TABLE IS NUMBER;

    Surlabasedesdonneesdufabricantduballast ARRAY TYPE IS VARCHAR2 (50);

    l_sid sid;

    l_screated_date screated_date;

    l_slookup_id slookup_id;

    l_sdata surlabasedesdonneesdufabricantduballast;

    l_start NUMBER;

    ID IS of SELECT CURSOR of c_data, created_date, lookup_id, data1 FROM big_table WHERE id > = StartRowOptional AND id < = EndRowOptional;

    Reclist TYPE IS an ARRAY OF c_data % ROWTYPE;

    reclist REB;

    BEGIN

    l_start: = DBMS_UTILITY.get_time;

    OPEN c_data;

    LOOP

    Fetch the c_data COLLECT in BULK IN CER LIMIT fetchsize;

    BECAUSE me IN REB. FIRST... REB. LAST

    LOOP

    INSERT INTO values big_table2 (REB (i) user.user, REB (i) .created_date, recs (i) .lookup_id, (i) recs .data1);

    END LOOP;

    OUTPUT WHEN c_data % NOTFOUND;

    END LOOP;

    C_data CLOSE;

    COMMIT;

    Dbms_output.put_line ('Total elapsed:-' |) (DBMS_UTILITY.get_time - l_start) | "hsecs");

    EXCEPTION

    WHILE OTHERS THEN

    LIFT;

    END;

    /

    DISPLAY ERRORS;

    WARNING: the execution is completed with warning

    29/87 PLS-00302: component "DATA1" must be declared

    29/87 PL/SQL: ORA-00984: column not allowed here

    29/6 PL/SQL: statement ignored

    I get the error error above in the insert statement.

    Please can I get help to solve.

    I won't answer your question, but say you something else - do not do this with bulk collect. Do it in a single SQL statement.

    Stop using loops and by engaging in loops.

    Who will solve the error, makes it less likely, you get error ORA-01555, create less recovery and be more effective.

    Oh, and it does nothing useful:

    EXCEPTION

    WHILE OTHERS THEN

    LIFT;

    The entire procedure should be:

    CREATE OR REPLACE PROCEDURE bulk_collect_limit (startrow IN NUMBER,endrow IN NUMBER,fetchsize IN NUMBER)
    IS
    
     l_start NUMBER;
    
    begin
    
    insert into big_table2(put a column list here for crikey's sake)
    select id,created_date,lookup_id,data1 FROM big_table WHERE id >= startrow AND id <= endrow;
    
    DBMS_OUTPUT.put_line('Total Elapsed Time :- ' || (DBMS_UTILITY.get_time - l_start) || ' hsecs');
    
    end;
    
  • Cursor Bulk Collect

    Hi all
    I have a doubt about cursor in block collection. Both versions work correctly.

    1st Version: 
    DECLARE
      CURSOR c1 IS (SELECT t2 FROM test10);
      TYPE typ_tbl IS TABLE OF c1%rowtype;
      v typ_tbl;
    BEGIN
      OPEN c1;  
        FETCH c1 BULK COLLECT INTO v;
      CLOSE c1;
      FOR i IN v.first..v.last
      LOOP
        DBMS_OUTPUT.PUT_LINE(v(i).t2);
      END LOOP;  
    END;
    
    2nd version: 
    DECLARE
      CURSOR c1 IS (SELECT t2 FROM test10);
      TYPE typ_tbl IS TABLE OF c1%rowtype;
      v typ_tbl;
    BEGIN
      OPEN c1;
      LOOP                                                 --Loop added
        FETCH c1 BULK COLLECT INTO v;
        EXIT WHEN c1%NOTFOUND; 
      END LOOP;
      CLOSE c1;
      FOR i IN v.first..v.last
      LOOP
        DBMS_OUTPUT.PUT_LINE(v(i).t2);
      END LOOP;  
    END;
    Is it necessary to have a loop and exit the statementwhen notfound cursor used with bulk collect?

    Published by: SamFisher February 14, 2012 13:26

    SamFisher wrote:
    for idx in (SELECT FROM test10 t2)
    loop

    end loop;

    But in doing so, context switches will be more aint't it?

    Yes, you will need to switch between SQL and PL/SQL, which is one of the penalties you pay to use the PL/SQL when SQL is necessary (don't tell is your case here, just a generality). However, that there are compromises. Memory is a limited product, it is expensive and you do not have an infinite amount. It is not as effective to spend many thousands of records in memory and then apply to processes that together, if you bulk load a bit, process a little you avoid exhaust any given resource (CPU, memory, etc...).

    As I said, Oracle will use a fetch array of 100, instead of X, where X is the number of records your query when you use a bulk collect without LIMITS. If you had to carry 10 000 magazines across the room, do you think you would sooner do 100 at a time and do a lot of travel or find a way to carry all the 10,000 in a trip?

    If you are interested in the analysis comparative differences, set up a simple table and load 100,500,1000,10000,100000, etc... documents in it and see what look like processing times.

    For versatile use, the implicit cursor loop wins hands down for each perspective (my opinion). Yet once again, assuming that you NEED pl/sql at all.

    Published by: Tubby on February 14, 2012 11:41

  • Using the slider for and BULK COLLECT INTO

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

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

    Best regards
    Val

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

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

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

Maybe you are looking for

  • Satellite P300-1gn starts up it free or by touching the Mute button

    My satellite P300 1gn starts that it self.It starts also toutching the Mute button or button CD (they are part of the extra of the enlightened next buttons set the power button. Is it possible to disable these keys additional lluminated? I wonder tha

  • Qosmio G20 154: not all digital channels under MCE

    Anyone know why under MCE not all digital channels are tuned, all using the Cyberlink Cinema Manager all channels are tuned regularly?Thank you Enzo-ita Skype

  • How to install Windows XP in Satellite A210-14 - need info step by step

    I'm not an expert on the Installation of the OS. I've heard many people how complicated to install WXP Vista laptop. Is it a document, how to do step by step? What should I do first? My labtop will work 100% once I installed Windows XP Home edition?

  • Copy traced the Clipboard?

    Hello Is it possible to copy an individual piece of the display or the report to the Clipboard, please?  (I know that you can copy the entire page of the report to the Clipboard). Thank you Martin

  • IX2 - dl does not start after the firmware update

    I bought my ix2 - dl last three days ago and then she starting with 2 new readers just to test it worked using Mac and Windows then a firmware update version 4.0.8.23976 appeared available via the web interface. After the update and reboot, it no lon