Query Nested table (collection)

I try to query on a nested table (collection).
How ever, I get a 600 error.
Is there any way to reuse the result of query in the store procedure?
SQL> DECLARE
2 TYPE T_PER_ID IS TABLE OF PERIOD.PER_ID%TYPE;
3 V_EXP_PER_ID T_PER_ID;
4 V_EXP_PER_ID2 T_PER_ID;
5 BEGIN
6 SELECT PER_ID BULK COLLECT INTO V_EXP_PER_ID FROM PERIOD;
7 SELECT * BULK COLLECT INTO V_EXP_PER_ID2 FROM TABLE(V_EXP_PER_ID);
8 END;
9 /
DECLARE
ERROR at line 1:
ORA-00600: internal error code, arguments: [15419], [severe error during PL/SQL
execution], [], [], [], [], [], []
ORA-06544: PL/SQL: internal error, arguments: [pfrrun.c:pfrbnd1()], [], [], [],
ORA-06553: PLS-801: internal error [0]

Oracle Version 8.1.6

Similar Messages

  • Nested table collection in select query "in clause" taking long time

    create or replace type t_circuitids is table of varchar2(100);
    --Below anonymous block keeps on running and never ends
    DECLARE
       v_circuitid    t_circuitids;
       v_count number;
       l_circuitids   VARCHAR2 (4000)
          := 'value1,value2,value3,value4,value5';
    BEGIN
    --Below query converts comma concatinated output to list and stores in nested table collection v_circuitids
       WITH a AS
            (SELECT ',' || l_circuitids || ',' AS circuitid
               FROM DUAL)
       SELECT DISTINCT TRIM (SUBSTR (circuitid,
                                     INSTR (circuitid, ',', 1, LEVEL) + 1,
                                       INSTR (circuitid, ',', 1, LEVEL + 1)
                                     - INSTR (circuitid, ',', 1, LEVEL)
                                     - 1
                            ) cid
       BULK COLLECT INTO v_circuitid
                  FROM a
            CONNECT BY LEVEL <
                             LENGTH (circuitid)
                             - LENGTH (REPLACE (circuitid, ','));
       SELECT COUNT (1)
         INTO v_count
         FROM table
        WHERE name IN (SELECT COLUMN_VALUE
                                          FROM TABLE (v_circuitid));
    END;
    --I got the issue, query "SELECT COLUMN_VALUE FROM TABLE (v_circuitid)" which is used in above code is responsible for this.
    --Same code works fine in Development and Test environments, But in prod it keeps on running
    --I solved this issue by creating a temp table, loading all values in collection into the temp table and using that temp table in "in clause"    "
    --Can any one answer why its behaving like this when i use collection in where clause?
    --I am using Oracle 9i

    Below is the code i used
    DECLARE
       v_circuitid    t_circuitids;
       v_count number;
       l_circuitids   VARCHAR2 (4000)
          := 'value1,value2,value3,value4,value5';
    BEGIN
    --Below query converts comma concatinated output to list and stores in nested table collection v_circuitids
       WITH a AS
            (SELECT ',' || l_circuitids || ',' AS circuitid
               FROM DUAL)
       SELECT DISTINCT TRIM (SUBSTR (circuitid,
                                     INSTR (circuitid, ',', 1, LEVEL) + 1,
                                       INSTR (circuitid, ',', 1, LEVEL + 1)
                                     - INSTR (circuitid, ',', 1, LEVEL)
                                     - 1
                            ) cid
       BULK COLLECT INTO v_circuitid
                  FROM a
            CONNECT BY LEVEL <
                             LENGTH (circuitid)
                             - LENGTH (REPLACE (circuitid, ','));
       SELECT COUNT (1)
         INTO v_count
         FROM table
        WHERE name IN (SELECT COLUMN_VALUE
                                          FROM TABLE (ccard(v_circuitid)));
    END;
    And got below error
    ORA-06550: line 27, column 5:
    PL/SQL: ORA-00906: missing left parenthesis
    ORA-06550: line 24, column 4:
    PL/SQL: SQL Statement ignored

  • What is Varray,Nested tables,Collections,Pragma?

    Hi,
    what is Varray,Nested tables,Collections,Pragma?
    and in Which Situations will We Use this?.
    Anyone having any dea regarding this?

    http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96624/05_colls.htm
    http://awads.net/wp/2006/03/01/pragmatism-in-oracle-plsqlKhurram

  • Querying Nested Table......

    Hi,
    I am new to this nested table topic, I am facing problem in querying nested table. Actually i had created a table which consists of details regarding Applications and the platforms. As an application can run on more than one platform i had created a nested table for platform.
    CREATE OR REPLACE TYPE TY_PLATFORM AS OBJECT
    (           VC_PLATFORM VARCHAR2(64)          );
    CREATE OR REPLACE TYPE NT_TY_PLATFORM AS TABLE OF TY_PLATFORM;
    I am using this nested table in the main table application:
    CREATE TABLE T_APPLICATION
    ( N_APPLICATION_ID NUMBER(32,6),
         VC_APPLICATION_NAME VARCHAR2(160),
    CL_NT_PLATFORM NT_TY_PLATFORM )
    NESTED TABLE CL_NT_PLATFORM STORE AS CL_NT_PLATFORM_TAB
    The table contains the data like this(Just for example):
    N_APPLICATION_ID VC_APPLICATION_NAME PLATFORM
    1 ABC Unix, Windows
    2 DEF Unix, MVS
    3 GHI Unix, Windows
    4 JKL Unix, Windows, MVS
    I have created the scripts like this...
    INSERT INTO T_APPLICATION(N_APPLICATION_ID, VC_APPLICATION_NAME) VALUES(1,'ABC');
    Like that for all applications...
    UPDATE T_APPLICATION SET CL_NT_PLATFORM=NT_TY_PLATFORM(TY_PLATFORM('Unix'),TY_PLATFORM('Windows')) WHERE N_ACCESS_NUMBER=1;
    Like that for all applications.....
    After creation i had queried
    SQL> select t.n_application_id from t_application t,table(cl_nt_platform)p
    2 where p.vc_platform='Unix' and p.vc_platform='Windows' and p.vc_platform!='MVS';
    no rows selected
    Actually i want the application list which run on unix and windows platform but not MVS
    It want the result like this:
    T.N_APPLICATION_ID
    1
    2
    but it is returning no rows selected.......
    Please help me......
    Thanks in advance.....

    Wrong forum my friend. This forum is for XML DB related issues, and while we use nested tables, we never have to worry about those nasty objects that were generated by XML Schema registration :)...
    I think you need...
    Objects

  • Reg: Querying Nested table.

    Hi,
    I am facing a problem with querying the Nested table.
    I have created a type
    CREATE OR REPLACE TYPE TY_BOOKS OBJECT(           VC_BOOK_NAME VARCHAR2(64)          );
    CREATE OR REPLACE TYPE NT_TY_BOOKS AS TABLE OF TY_BOOKS;
    I have used this nested table in a table Student.
    CREATE TABLE STUDENT
    ( SID NUMBER(10),
    CL_NT_BOOKS NT_TY_BOOKS)
    NESTED TABLE CL_NT_BOOKS STORE AS CL_NT_BOOKS_TAB;
    The problem is one student can have more than one book. So if I need to select the students who have 'Science' books, i wrote this query.
    SELECT S.SID,B.VC_BOOK_NAME FROM STUDENT S, TABLE(CL_NT_BOOKS) B WHERE B.VC_BOOK_NAME='Science';
    suppose in the table
    SID BOOK_NAME
    1000          CL_NT_BOOKS('Science')
    1001          CL_NT_BOOKS('Maths'),CL_NT_BOOKS('Science')
    This query will return only those student-ids who have only "Science" book not those student-ids who have "Maths" & "Science" books.
    RESULT
    1000          Science
    but not 1001....
    Please can any one send me the select query which can select iteratively for books names which contains more than one value.

    Hmm, mysterious. It works for me on my 9.2.0.6 dB...
    SQL> CREATE OR REPLACE TYPE TY_BOOKS AS  OBJECT( VC_BOOK_NAME VARCHAR2(64) );
      2  /
    Type created.
    SQL> CREATE OR REPLACE TYPE NT_TY_BOOKS AS TABLE OF TY_BOOKS;
      2  /
    Type created.
    SQL> CREATE TABLE STUDENT
      2  ( SID NUMBER(10),
      3  CL_NT_BOOKS NT_TY_BOOKS)
      4  NESTED TABLE CL_NT_BOOKS STORE AS CL_NT_BOOKS_TAB;
    Table created.
    SQL> INSERT INTO student VALUES (1000, NT_TY_BOOKS(TY_BOOKS('Science')))
      2  /
    1 row created.
    SQL> INSERT INTO student VALUES (1001, NT_TY_BOOKS(TY_BOOKS('Science'),TY_BOOKS('Maths')))
      2  /
    1 row created.
    SQL>
    SQL> SELECT S.SID,B.VC_BOOK_NAME FROM STUDENT S, TABLE(CL_NT_BOOKS) B
      2  WHERE B.VC_BOOK_NAME='Science'
      3  /
           SID VC_BOOK_NAME
          1000 Science
          1001 Science
    SQL> What I suggest is most likely to have happened is that you have added a space or some other non-printing cahracter into the book name when you inserted row 1001. If this is not the case then you'll have to do it again in SQL*Plus, cut teh output and paste it here, so we can see what's going on.
    Cheers, APC

  • Querying Nested Tables from BO

    Hi,
    I have a nested table [VA_GT_HC_ASIA_SGP ] in Oracle. The Inner Object in the nested table has got 4 columns, which has to be displayed in the WebI Report.
    Hece I created the table as derived table in Universe by the below query.
    select a.COL1, b.COL2, b.COL3, b.COL4, b.COL5 from VA_GT_HC_ASIA_SGP a, Table(a.OB_GT_HC_MAINT_INFO) b
    But performance is very slow. Please advice if there exists a better way to do this.
    Best Regards,
    Anu

    The Query is:-SELECT A.ID, A.NAME, A.COMB, B.C1,B.C2, B.C3  FROM NT_KFD_RFT_TEST_DATE A, TABLE(OB_KFD_RFT_DATA) B
    Nested Table structure Example:-
    ID       NAME    COMB   OB_KFD_RFT_DATA
    01      TEST     ALL    
    The inner table (OB_KFD_RFT_DATA) structure is
    C1      C2        C3
    23.5   56.7   78.9
    00.9   76.9   53.3
    12.4   33.4   23.2
    Here outer record is 01 TEST ALL, and inner record is the 3 row decimal numbers.
    In Universe, I need to create Objects from C1,       C2,      C3 columns.
    Currently i'm doing it with derived table (by running above query). Is there any other option to do it?
    Thanks,
    Anu

  • Querying Nested Tables with Multiple other Tables

    I am trying to query columns from a table and it's nested table and do a join to another table.
    SELECT IM.*,
    IMP.PROGRAM_ID,
    S.STAGE_NAME
    FROM TB_ITEM_MASTER IM , TABLE(TB_ITEM_MASTER.PROGRAMS) IMP, TB_STAGE S
    WHERE S.STAGE_ID = IM.STAGE_ID
    AND IM.PROGRAM_ID IN(1,2);
    When running this query I receive the error:
    ORA-00904:"TB_ITEM_MASTER"."PROGRAMS": Invalid Identifier
    I actually copied this query straight from an Oracle Documentation, just replaced my table names with theirs. This query will almost be like a template to me as the program_id field in the Nested table is very cruicial to me. I will joining many tables to TB_ITEM_MASTER and using the where clause against program_id. What's the problem here?
    Please advise.
    ps. Did I mention how much I hate working with this Nested table stuff:(

    You must use the alias name, not the table name.
    SQL> create type employee_obj as object (empno number) ;
      2  /
    Type created.
    SQL> create type employees_nt is table of employee_obj ;
      2  /
    Type created.
    SQL> create table departments (deptno number(2), dname varchar2(20), employees employees_nt)
      2  nested table employees store as employees_table
      3  /
    Table created.
    SQL> insert into departments values (1, 'DEPT #1', employees_nt(employee_obj(2), employee_obj(3))) ;
    1 row created.
    SQL> insert into departments values (22, 'DEPT #2', employees_nt(employee_obj(22), employee_obj(33))) ;
    1 row created.
    SQL>
    SQL> SELECT IM.*,
      2  IMP.empno
      3  FROM departments IM , TABLE(IM.employees) IMP
      4  WHERE IM.deptno IN(1,2);
        DEPTNO DNAME
    EMPLOYEES(EMPNO)
         EMPNO
             1 DEPT #1
    EMPLOYEES_NT(EMPLOYEE_OBJ(2), EMPLOYEE_OBJ(3))
             2
             1 DEPT #1
    EMPLOYEES_NT(EMPLOYEE_OBJ(2), EMPLOYEE_OBJ(3))
             3
    2 rows selected.
    SQL>

  • Query nested table?

    Let's say I have an object type "pair" with elements "name" and "value". I create a nested table type "pairtable" of type "pair". Then I create a view, "view", that has a column "nametable". The values in "nametable" are the result of a function that takes the value in the first column of the view, "id", and builds a nested table of type "pairtable" with the "names" and "values" associated with "id" that are stored in other tables. Clear as mud, yes?
    If I type this into SQL+
    select * from view where id = 100
    I get
    id col2 col3 col4 nametable
    100 A B C pairtable(pair(aname, avalue)),pairtable(pair(bname, bvalue)),...
    What I want is a cursor that contains only the "names" and "values" from a select number of "id"s.
    What is the syntax?
    Database is 8i, client is 9.2.
    (p.s. Eventually I will want to call these name value pairs from .NET as a REF Cursor. For now I will settle for something that works in PL/SQL)

    Ross,
    OLEDB does not support object types or nested table. This restriction is limited by the Microsoft OLEDB specfication.
    This forum is for ODP.NET. You may want to post this question to OLEDB forum.
    Thanks
    Martha

  • Query hangs using db link and nested table collection

    Hi,
    I have a stored procedure which takes, as input, a string of values that can vary in length. The input is used as an IN operator within the queries that exist within the proc:
    Code:
    PROCEDURE get_contacts (i_customerids IN VARCHAR2)
    an example of the input would be: '987451',412897' or '7541256','75412','95412589'
    In order to process the dynamic "In-List", I created a custom collection type to convert the string to a table:
    Code:
    CREATE OR REPLACE
    TYPE stringtotable AS TABLE OF VARCHAR2(3900)
    (I've also tried the solutions on http://tkyte.blogspot.com/2006/06/varying-in-lists.html and http://fdegrelle.over-blog.com/article-1694534-6.html for handling dynamic in-lists and they also hang)
    The proc contains 2 queries, the first returns records from a table within the current database:
    Code:
    SELECT *
    FROM contacts
    WHERE customer_id IN (
    SELECT *
    FROM TABLE (stringtotable (i_customerids
    The second query returns records from a database that is defined via a db link:
    Code:
    SELECT b.customer_id, a.row_id, a.fst_name, a.last_name
    FROM userlist.customers@uldblink a, userlist.firms@ulbdlink b
    WHERE a.parent_id = b.row_id
    AND b.customer_id IN (
    SELECT *
    FROM TABLE (stringtotable (i_customerids
    The first query is executing without issue. The second query, however, is hanging indefinitely. Additionally, If I hard code the string in the IN operator, the second query executes without issue.
    I am not the DBA for the database, so I don't currently have access to the trace logs. I've requested access to the trace logs to see if I can figure out what is hanging.
    In the meantime, I was hoping someone would be able to tell me if
    a: there is a better way to handle "dynamic in- lists".
    or
    b: if there is something obvious that I'm not considering.
    Thanks for your help,
    Fielding
    Message was edited by:
    fwilson

    Hi Todd,
    Thanks for the suggestion. I was not aware of the cardinality hint.
    I tried adding it to my query but unfortunately the query still appeared to hang. It did get me thinking though... that maybe the stringtotable collection type is creating the table in memory, and therefore its records aren't accessible to the dblink
    so I inserted the values that were being returned via the stringtotable collection type into a physical table named TestTable. I then modified my query to select the values from TestTable.
    Code:
    ...in (select /*+ cardinality(t 3) */ t.*
    from testtable t)
    This worked.
    So that poses the questions-
    a: is my assumption about the in-memory table correct
    and
    b: if so is there a way around it?
    Thanks for your help

  • Associative Array to Nested Table: Anything faster?

    (First Post! Some ASP.NET references, but I think this really is a PL/SQL question)
    I work on a team that runs an Oracle instance for data warehousing and reporting along with an ASP.NET based website for display.
    Sometimes, I may want to have many parameters come in and only show records that match those parameters. For example, I may want to show all employees who are Managers or Developers and not show employees who are Accountants or Scientists. Typically, I send a parameter into my PL/SQL stored procedures as an associative array (as declared in my package specification). Once in the procedure, I convert that associative array into another associative array (as a user created SQL type) and then I'm able to use it like a nested table to join on.
    My question is: in your experience, is there any way to get around this type conversion or another faster way?
    For example:
    -- Create the sql type
    CREATE OR REPLACE TYPE DIM.sql_string_table AS TABLE OF VARCHAR2(255);
    --pretend that this works and it's in a package body
    declare
    type string_table is table of varchar2(255) index by binary_integer;
    l_job_types string_table; -- Keep in mind I'd normally be sending this via ASP.NET
    l_job_types_nested sql_string_table := sql_string_table();
    begin
    -- Add some data
    l_job_types(0) := 'Manager';
    l_job_types(1) := 'Developer';
    -- Do the conversion
    for i in l_job_types.first .. l_job_types.last
    loop
    l_job_types_nested.extend;
    l_job_types_nested(l_job_types_nested.count) := l_job_types(i);
    end loop;
    -- get some data out (we're pretending)
    open fake_ref_cursor for
    Select e.*
    from employees e,
    the(select cast(l_job_types_nested as sql_string_table) from dual) jobs_types_wanted
    where e.type = value(jobs_types_wanted);
    end;
    The result would be all employees whose have a type that was input into the l_job_types associatve array.
    See: http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:110612348061
    for additional reference

    > I convert that associative array into another associative array (as a user created SQL type)
    Just so we're clear, Oracle use the term 'associative array' to refer to the exclusively PL/SQL sparse collection type ("table of x index by pls_integer" etc) as distinct from the common nested table collection type.
    Also I could be wrong but I think
    SELECT ..
    FROM   the(select cast(l_job_types_nested as sql_string_table) from dual) jobs_types_wantedis generally the same as
    SELECT ..
    FROM   TABLE(l_job_types_nested) jobs_types_wantedthough "SELECT *" and implicitly collection casting don't always mix. The "THE()" syntax is deprecated.

  • Nested tables questions

    I ve been using nested tables ( with the 'index by' clause ).
    I understand that the created array is stored in the RAM memory ( and not in the database files ).
    1. Does this mean that my program might not run one day when the machine is running low on RAM ?
    2. If yes, will there be an exception or something ?
    3. I understand that the memory is freed when the 'session ends'. When does my session end ? ( Is it when my PROCEDURE/function ends or is it when I quit sqlplus )
    4. Are nested tables/collections thread safe ?
    If I declare a nested table within the procedure, and if the procedure is called simultaneously by two clients, will there be a problem ?
    Thanks

    1. Yes
    2. Yes, possibly "PLS-00996: out of memory" although there may be others
    3. PL/SQL does garbage collection at various times, including when your session ends (i.e. when you disconnect from Oracle) and when a variable goes out of scope (e.g. when a procedure ends). I don't think the full list of rules is documented.
    4. Yes, although I'm not sure what happens in connection pooling.

  • Problem with Nested Table

    I am trying to make a nested table receive an arbitrary number of values (from a shuttle) through a loop, and then insert the table into a table of nested table in my database. The problem I am having is that when I try to insert more than one value into the nested table, it will only insert the last item in the loop into the database. Thanks in advance.
    This is the code I used to create my objects:
    create or replace type OUTPUT_TY as object( ATTRIBUTE_ID Number(8) )
    create or replace type OUTPUTS_NT as table of OUTPUT_TY
    This is my actual code in ApEx:
    declare
    temp_NT OUTPUTS_NT;
    temp_TY OUTPUT_TY;
    temp Number(10);
    l_vc_arr2 htmldb_application_global.vc_arr2;
    begin
    temp_nt := outputs_nt();
    l_vc_arr2 := HTMLDB_UTIL.string_to_table (:P2_SHUTTLE, ':');
    FOR i IN 1 .. l_vc_arr2.COUNT
    LOOP
    temp_ty := output_ty(l_vc_arr2(i)) ;
    temp_NT:= outputs_nt(temp_ty);
    END LOOP;
    INSERT INTO OUTPUT_TEST values (temp_NT);
    commit;
    end;

    > temp_NT:= outputs_nt (temp_ty);You are not extending the nested table / collection, you are simply assigning an entirely new collection to it for each element of l_vc_arr2.
    Try something like...
    FOR i IN 1 .. l_vc_arr2.COUNT LOOP
       temp_ty := output_ty (l_vc_arr2 (i));
       temp_nt.EXTEND;
       temp_nt (temp_nt.LAST) := temp_ty;
    END LOOP;Or perhaps more succintly...
    FOR i IN 1 .. l_vc_arr2.COUNT LOOP
       temp_nt.EXTEND;
       temp_nt (temp_nt.LAST) := output_ty (l_vc_arr2 (i));
    END LOOP;

  • Collections stored as Nested tables

    I have created a Table with XMLTYPE column and the
    column is defined as Object against a registered Schema.
    I have also created nested tables for all collection types
    and created appropriate indexes on the Nested tables
    based on Nested_table_Id and array_index.
    CREATE TABLE STATEMENT_DATA
    TEST SYS.XMLTYPE
    XMLTYPE COLUMN TEST STORE AS OBJECT RELATIONAL
    XMLSCHEMA "StatementData.xsd"
    ELEMENT "StatementData"
    varray TEST."XMLDATA"."MessagePayload"."BillDeterminant"
    STORE AS table BillDeterminant
    ( varray "AttributeList" STORE AS table BillDtr_AttrList,
    varray "ChargeProfileData" STORE AS table BillDtr_ProfData )
    varray TEST."XMLDATA"."MessagePayload"."MarketStatement"
    STORE AS table MarketStatement
    (varray "MarketStatementLineItem" STORE AS table marketlineitm
    ( varray "PassThroughBill"."AttributeList" STORE AS table Lineitm_ChargeProf_AttrList,
         varray "PassThroughBill"."ChargeProfile" STORE AS table Lineitm_ChargeProfile
         (varray "ChargeProfileData" STORE AS table ChargeProfileData),
         varray "AttributeList" STORE AS table Lineitm_AttributeList),
         varray "RTO" STORE AS table Rto
         (varray "ErpAddress" STORE AS table rto_ErpAddress,
              varray "ErpPerson" STORE AS table rto_Erpperson
              (varray "ErpTelephoneNumber" STORE AS table rto_ErpTelephoneNumber)) ,
         varray "Customer" STORE AS table Customer
         (varray "ErpAddress" STORE AS table Cust_ErpAddress,
              varray "ErpPerson" STORE AS table cust_Erpperson
              (varray "ErpTelephoneNumber" STORE AS table cust_ErpTelephoneNumber)) ,
    varray "ActivityRecord" STORE AS table ActivityRecord)
    Sample Index :
    CREATE UNIQUE INDEX MARKETLINEITM_indx1 ON MARKETLINEITM d
    ( d.NESTED_TABLE_ID,d.array_index);
    Now when I tried to execute a sample query involving some of the
    nested tables , Explain Plan shows that it is not using the indexes
    I have created.
    The following parameters are also set in the Database.
    query_rewrite_enabled : TRUE
    query_rewrite_integrity : TRUSTED.
    I am using Oracle 9.2.0.5.0.
    Can somebody tell me if I am missing something?
    Thanks,
    Arun

    Thanks for the reply. XMPTYPE based column is not using the
    indexes even after gathering Index statistics. However the Statistics
    gathering is helping queries based on XMLTYPE based tables.
    Any suggestion for XMLTYPE based columns ? Has anybody
    been able to successfully use the indexes in 10g ?
    Arun

  • Nested Tables select query soooooo slow

    I know that varrays are supposed to be used for small arrays. But, we are comparing nested tables to varrays and two table joins. Nested table query is unimaginably ,unacceptably slow.
    Is there anybody else out there who experienced the same thing. Are there ways to speed up the select queries.(besides indexes)

    If you try to use nested sql statement. Please be sure to setup the index to some specific tables inside oracle
    Doing this will speed up your performance about 5 ~ 9 times original.
    [email protected]

  • Sql query, from xml to nested table

    Hello!
    I have DB table: my_table
    It has 2 fields: file_id and file_data (it's clob with xml)
    I need to write query that returns info from xml using nested table (Oracle v.9)
    The number of rows witch will return query must be equal to number of files (file_id)
    Structure of XML:
    <?xml version = "1.0" encoding = "utf-8"?>
    <head>
    <AAA v1="a" v2="b">
    <BBB p1="1" p2="2"/>
    <BBB p1="3" p2="4"/>
    </AAA>
    <AAA v1="c" v2="d">
    <BBB p1="5" p2="6"/>
    <BBB p1="7" p2="8"/>
    <BBB p1="9" p2="0"/>
    </AAA>
    </head>
    I have query, witch works! but not optimally! each CLOB scaned 3 times - I want to scan it once!
    SELECT an.file_id,
    CAST(MULTISET(SELECT extract(VALUE(val2),'//@v1').getStringVal() v1,
    extract(VALUE(val2),'//@v2').getStringVal() v2,
    CAST(MULTISET(SELECT extract(VALUE(val3),'//@p1').getStringVal() p1,
    extract(VALUE(val3),'//@p2').getStringVal() p2,
    FROM TABLE (XMLSEQUENCE(XMLTYPE(an.file_data).EXTRACT('/head/AAA/BBB[../@v1='||extract(VALUE(val2),'//@v1').getStringVal()||']'))) val3) AS T_VAL3) info
    FROM TABLE (XMLSEQUENCE(XMLTYPE(an.file_data).EXTRACT('/head/AAA'))) val2) AS T_VAL2) head
    FROM (SELECT olr.*
    FROM my_table olr,
    TABLE (XMLSEQUENCE(XMLTYPE(file_data)).EXTRACT('/head'))) val1) an
    PLEASE, help me to rewrite this query!

    I assume you're using nested objects like these to hold the result?
    create type t_val3_rec as object ( p1 number, p2 number );
    create type t_val3 as table of t_val3_rec;
    create type t_val2_rec as object ( v1 varchar2(30), v2 varchar2(30), c1 t_val3 );
    create type t_val2 as table of t_val2_rec;
    /then this query should work :
    SELECT t.file_id
         , CAST(
             MULTISET(
               SELECT extractvalue(value(x1), '/AAA/@v1')
                    , extractvalue(value(x1), '/AAA/@v2')
                    , CAST(
                        MULTISET(
                          SELECT extractvalue(value(x2), '/BBB/@p1')
                               , extractvalue(value(x2), '/BBB/@p2')
                          FROM TABLE(XMLSequence(extract(value(x1), '/AAA/BBB'))) x2
                        AS t_val3
               FROM TABLE(XMLSequence(extract(value(x), '/head/AAA'))) x1
             AS t_val2
    FROM my_table t
       , TABLE(XMLSequence(extract(xmltype(t.file_data), '/head'))) x
    ;

Maybe you are looking for

  • No column heading in second page in alv report when save in excel file

    Hi Expert, How can i remove the column header from Alv report when program execute in background and save in excel file right now its comming column header in each page. Client dont want header column in excel from second page. is this possible? with

  • Will Hyper-V Replication Manager move a VM without shutting it down?

    Scenario Let say I have two sites (Primary And DR). I have my production VM's running on my Primary Site.  If I protect them with Hyper-V Replica the VM is replicated and I can bring the VM up manually in the DR site. So I know that process work. I a

  • Stop and start database for cold backup

    Hi, Database :Oracle 10g R1 OS : Red hat 3 I have a RAC database with 2 nodes. I build this script to make a cold backup of the database. (I will put it in the cron tab). My question is the SRVCTL will work in this scripts?? # ***** COLDBACKUP ORACLE

  • Help! G3 freaking out/kernel panic/memory problems

    Hi All, I put some pc 133 512 mb memory in my G3 [which is actually pc 100, but supposedly should work fine] and then it kernel paniced. Now it mostly seems to recognize memory in the slot closest to the screen. But only 64 and 32 mb sticks. Plus, it

  • Finding the number of Non-Blank Line in a File

    Does anyone know the command or how to find the number of non-blank lines in a text file? I have the program already reading characters, words, and total lines.           BufferedReader FileIn = new BufferedReader( new FileReader( selectedFile ) );