Selecting from XMLType

I'm trying to execute 'insert ... select' statement inside PL/SQL stored procedure using xmlsequence function and get the folloving error:
SQL> declare
2 i_xml xmltype;
3 begin
4 select xml
5 into i_xml
6 from i_query_xml;
7 insert into t
8 select extractvalue(value(t),'//ENTITY/@NAME')
9 from table ( xmlsequence(extract(i_xml,'//TERMS/ENTITY')) ) t;
10 end;
11 /
declare
ERROR at line 1:
ORA-22905: cannot access rows from a non-nested table item
ORA-06512: at line 7
The same code works good when selecting from a table contaning XMLType column.
Should I perform some kind of casting operation on the result of xmlsequence function?

Does the following code look different? It works great.
begin
insert into t
select extractvalue(value(t),'//ENTITY/@NAME')
from i_query_xml x, table ( xmlsequence(extract(x.xml,'//TERMS/ENTITY')) ) t;
end;
Thanks

Similar Messages

  • How to avoid ORA-3113 when selecting from XMLTYPE table

    Hi,
    If I register an XML-schema, Oracle automatically creates a table xxxxxx_tab of XMLTYPE. (I use Oracle 9.2.0.1)
    When I do a DESCRIBE or a SELECT from this table I get the error: 'ORA-03113:
    end-of-file on communication channel' and my connection is dropped.
    I opened a TAR for this and Oracle says: 'It is an internal bug so cannot be viewed in metalink. This is fixed in release 10i.' (do they mean oracle DB rel 10i, or a new version of XDK?)
    I saw an example in Oracle Magazine (Jan
    2003) "Make XML Native and Relative" about Oracle 9i Rel 2 and XML. As you can see in codeListing 7, the author also does a select from such a
    table (CD331_tab): Why doesn't he have any problems?
    Is there a workaround for this bug? What's the purpose of being able to automatically upload XML-data to a registered schema if you can't do a select of the data?
    Thank you!

    It appears that the XML Schema is not entirely valid. Specifically, the definition of element "DeviceCategory" has two definitions of element "Audio" appearing within a <choice> model i.e. something like :
    <element name="DeviceCategory">
    <choice>
    <sequence>
    <element name="Audio">
    </sequence>
    <sequence>
    <element name="Audio">
    </sequence>
    </choice>
    This is disallowed by XML Schema spec per. the Unique Particle Attribution Constraint. The general idea is that a XML Schema describes a determinstic content model i.e. schema processor can always unambiguosly determine the matching declaration when it encounters an element. However that's not the case with the declaration above. On encoutering "Audio", it could match either the first or the second declaration of the element. Hence the error.
    You will have to rework the schema to avoid this constraint. One mechanism could be to define complexType and their restrictions.
    - Ravi

  • Select from XMLTYPE column

    i have table with tow column recid and xmlrecord (xmltype)
    <row id="52843" xml:space="preserve">
    <c1>Refund of Domestic Payment Order</c1>
    <c2>Ref Dom Py Or</c2>
    <c3>PLl</c3>
    <c20>1</c20>
    <c21>62_TAABSINPUTT___OFS_TAABS</c21>
    <c22>0803181605</c22>
    <c23>62_TAABSINPUTT_OFS_TAABS</c23>
    <c24>SA0010001</c24>
    <c25>1</c25>
    </row>
    i need to select from table where <c24> =SA0010001
    please need help

    If you would have posted the XML path with nodes, I can provide the SQL with full path but try to use the below SQL changing their SQL path and root
    select extractValue(object_value, '/<XMLPath>/C24')
    as Id
    from invoicexml_tbl;
    If you want to use in WHERE clause, use existsnode method
    select * from invoicexml_tbl
    where existsNode(object_value, '/<XML Path>/row[c24="SA0010001"]') = 1;

  • Selecting from XMLTYPE table

    HI Gentlemen,
    Given a schema-based XMLTYPE table with one big XML instance stored in it. I would like to select a subtree like <gnr V="12345" ...> ... </gnr> where the attribute could be a bind parameter dynamically changing. As an output I would like to have the whole subtree with XML tags, for which I already have a perfectly good XSL stylesheet to display contents. It is working well when the subtree is stored in an .xml file which references the .xsl stylesheet. My question is: How can I organize that the ADF view is connected to the stylesheet and how can I apply all that to a .jspx ADF page? Updating the table is not a matter. Please help if you can.
    Thanks, regards
    Miklos HERBOLY

    If you already have the correct xsl file to use, you might consider creating a xsql page instead of a jspx page:
    http://people.cis.ksu.edu/~hankley/d764/tut05/Kamath_XSQL.html
    NA
    http://nickaiva.blogspot.com

  • Select from xmltype multiple rows not having XMLSequence in my db

    Hello every one
    i am new to use xml in pl/sql. we are using a db Oracle9i Enterprise Edition Release 9.0.1.4.0
    but we do not have XMLSequence so that i can not use select like
    SELECT e.DOCUMENT.extract(value(d), '/xs:schema/xs:complexType/xs:complexContent/xs:extension/xs:sequence/xs:element').GETSTRINGVAL() pi
    FROM XML_RESULTADO e,
    table(sys.xmlsequence (extract(value(x), '/xs:schema/xs:complexType/xs:complexContent/xs:extension/xs:sequence/xs:element'))) d
    where ID=2
    who is it possible to have the sesult in diffent rows?
    any help will be very apreciated
    many thanks
    ana

    You will probably can get a lot out of "Building Oracle XML Applications" of Steve Muench (http://www.amazon.com/Building-Oracle-Applications-Steve-Muench/dp/1565926919/ref=pd_rhf_p_t_1) if you can still find it in book form.
    It was off much use to me in the pre Oracle XMLDB era (aka 9.2.0.3.0). See if you can get hold on a copy. It is well worth it, very helpful regarding you kind of problems.
    Edited by: Marco Gralike on Jan 30, 2010 12:54 AM

  • 4.0 EA1 - Cannot select from table with xmltype

    Hi,
    I have the following table. When doing a select * from horus_owner.horus_objects nothing is shown. This could be reproduced with both 10g and 11g on the database-side.
    Regards,
    Johannes
    -- Wiedergabe von TABLE DDL für Objekt HORUS_OWNER.HORUS_OBJECTS nicht möglich, da DBMS_METADATA internen Generator versucht.
    CREATE TABLE HORUS_OWNER.HORUS_OBJECTS
      ID NUMBER(32, 0) NOT NULL
    , TRE_ID NUMBER(32, 0) NOT NULL
    , WRK_ID NUMBER(32, 0) NOT NULL
    , NAME VARCHAR2(200 BYTE) NOT NULL
    , MOD_TYPE VARCHAR2(10 BYTE) NOT NULL
    , LOCKED_BY VARCHAR2(30 BYTE)
    , PETRI_XML SYS.XMLTYPE
    , AOM_XML SYS.XMLTYPE
    , SHM_XML SYS.XMLTYPE
    , ORG_XML SYS.XMLTYPE
    , ROLE_XML SYS.XMLTYPE
    , MIT_XML SYS.XMLTYPE
    , RUL_XML SYS.XMLTYPE
    , TXT_DATA CLOB
    , CREATED DATE NOT NULL
    , CREATED_BY VARCHAR2(30 BYTE) NOT NULL
    , UPDATED_BY VARCHAR2(30 BYTE)
    , UPDATED DATE
    , SIM_XML SYS.XMLTYPE
    , GLOSSARY_XML SYS.XMLTYPE
    , CONSTRAINT OBJ_PK PRIMARY KEY
        ID
      ENABLE
    LOGGING
    TABLESPACE HORUS_OWNER_DATA
    PCTFREE 10
    INITRANS 1
    STORAGE
      INITIAL 65536
      NEXT 1048576
      MINEXTENTS 1
      MAXEXTENTS UNLIMITED
      BUFFER_POOL DEFAULT
    ) NOCOMPRESS
    XMLTYPE PETRI_XML STORE AS CLOB
    XMLTYPE AOM_XML STORE AS CLOB
    XMLTYPE SHM_XML STORE AS CLOB
    XMLTYPE ORG_XML STORE AS CLOB
    XMLTYPE ROLE_XML STORE AS CLOB
    XMLTYPE MIT_XML STORE AS CLOB
    XMLTYPE RUL_XML STORE AS CLOB
    LOB (TXT_DATA) STORE AS SYS_LOB0000024538C00021$$
      ENABLE STORAGE IN ROW
      CHUNK 8192
      RETENTION
      NOCACHE
      LOGGING 
    XMLTYPE SIM_XML STORE AS CLOB
    XMLTYPE GLOSSARY_XML STORE AS CLOBALTER TABLE HORUS_OWNER.HORUS_OBJECTS
    ADD CONSTRAINT OBJ_UK UNIQUE
      WRK_ID
    , NAME
    , TRE_ID
    ENABLEALTER TABLE HORUS_OWNER.HORUS_OBJECTS
    ADD CONSTRAINT OBJ_TRE_FK FOREIGN KEY
      TRE_ID
    REFERENCES HORUS_OWNER.HORUS_TREE_NODES
      ID
    ENABLEALTER TABLE HORUS_OWNER.HORUS_OBJECTS
    ADD CONSTRAINT AVCON_1243352806_MOD_T_000 CHECK
    (MOD_TYPE
    IN ('EMP', 'ROL', 'ENT', 'OCH', 'XML', 'SHM', 'OSM', 'BUM', 'BOM',
    'BEH', 'KPI', 'RIS', 'SER', 'STR', 'SWO', 'AOM', 'CON', 'GOA', 'BUR'
    , 'BPA', 'RES', 'SIM', 'GLO','TEM', 'SAR'))
    ENABLECREATE UNIQUE INDEX HORUS_OWNER.OBJ_PK ON HORUS_OWNER.HORUS_OBJECTS (ID ASC)
    LOGGING
    TABLESPACE HORUS_OWNER_IDX
    PCTFREE 10
    INITRANS 2
    STORAGE
      INITIAL 65536
      NEXT 1048576
      MINEXTENTS 1
      MAXEXTENTS UNLIMITED
      BUFFER_POOL DEFAULT
    NOPARALLEL
    CREATE INDEX HORUS_OWNER.OBJ_TRE_FK_I ON HORUS_OWNER.HORUS_OBJECTS (TRE_ID ASC)
    LOGGING
    TABLESPACE HORUS_OWNER_IDX
    PCTFREE 10
    INITRANS 2
    STORAGE
      INITIAL 65536
      NEXT 1048576
      MINEXTENTS 1
      MAXEXTENTS UNLIMITED
      BUFFER_POOL DEFAULT
    NOPARALLEL
    CREATE UNIQUE INDEX HORUS_OWNER.OBJ_UK ON HORUS_OWNER.HORUS_OBJECTS (WRK_ID ASC, NAME ASC, TRE_ID ASC)
    LOGGING
    TABLESPACE HORUS_OWNER_IDX
    PCTFREE 10
    INITRANS 2
    STORAGE
      INITIAL 65536
      NEXT 1048576
      MINEXTENTS 1
      MAXEXTENTS UNLIMITED
      BUFFER_POOL DEFAULT
    NOPARALLEL
    CREATE INDEX HORUS_OWNER.OBJ_WRK_FK_I ON HORUS_OWNER.HORUS_OBJECTS (WRK_ID ASC)
    LOGGING
    TABLESPACE HORUS_OWNER_IDX
    PCTFREE 10
    INITRANS 2
    STORAGE
      INITIAL 65536
      NEXT 1048576
      MINEXTENTS 1
      MAXEXTENTS UNLIMITED
      BUFFER_POOL DEFAULT
    NOPARALLEL

    Not sure if this helps, but I was trying to come up with some test cases myself and I noticed some strange behavior.  4 simple test cases:
    SELECT XMLTYPE('<OUTER><INNER>TEST</INNER></OUTER>') FROM DUAL;
    SELECT XMLELEMENT("OUTER", XMLELEMENT("INNER", 'TEST')) FROM DUAL;
    SELECT XMLELEMENT("OUTER", XMLAGG(XMLFOREST('TEST' "INNER"))) FROM DUAL;
    SELECT XMLQUERY('/OUTER' PASSING XMLTYPE('<OUTER><INNER>TEST</INNER></OUTER>') RETURNING CONTENT) FROM DUAL;
    1 and 2 return the xml string in the result grid column.  3 and 4 return (XMLTYPE) with no data in the pop-up editor when double clicking the result.  I changed #3 to:
    SELECT XMLELEMENT("OUTER", XMLFOREST('TEST' "INNER")) FROM DUAL;
    and it returns the XML string.
    I used undo to revert back to my original #3 and it started showing the XML string instead of (XMLTYPE) previously observed.
    I changed my connection to another schema, ran #3 again, and it went back to (XMLTYPE).  I tried to recreate the same behavior using the 2nd schema, but I was unable to get to show the XML string. 
    In any test case where I was getting the (XMLTYPE), I was not able to see data in the pop-up editor.
    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production    
    PL/SQL Release 11.2.0.3.0 - Production                                          
    CORE 11.2.0.3.0 Production                                                        
    TNS for HPUX: Version 11.2.0.3.0 - Production                                   
    NLSRTL Version 11.2.0.3.0 - Production 

  • How to get node value of XML file from XMLTYPE field of databases

    Hi,
    I want to select node value of XML from XMLTYPE field of oracle db into java code.
    Feel free to answer me if you have any idea about it.
    Thanks

    For XMLType refer
    http://www.oracle.com/oramag/oracle/01-nov/o61xml.html
    http://www.lc.leidenuniv.nl/awcourse/oracle/appdev.920/a96620/xdb04cre.htm

  • How to get result of Select from stored function.

    I need to get result of select from a stored function.
    In the end of my stored function I makes final select (four columns).
    How it can be retrived from function?

    Hi,
    A function can only return one value, but it sounds like you want to return 4 values.
    The one value that you return can be a record, with many columns, such as a ROWTYPE, or a TYPE that you define.
    You can return an XMLTYPE that has whatever elements you want.
    You can write a procedure that has several OUT parameters. (You can have OUT parameters in a function, but a lot of people find that confusing.)
    In very special circumstance, you might consider returning a string that is a delimited list of values, such as '7639,SMITH,,17-DEC-1980'.
    Someoneelse has a good point.
    We could give a better answer if you ask a specific question, like:
    "I have this table ...
    I want a function such that, if I call it with these parameters ... I get ...
    but if I call it like this ... then I get ..."

  • Populate collection type from XMLType

    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
    PL/SQL Release 11.1.0.7.0 - Production
    CORE     11.1.0.7.0     Production
    TNS for Linux: Version 11.1.0.7.0 - Production
    NLSRTL Version 11.1.0.7.0 - Production
    Please bear with me as I'm new to this XML DB thing and also this is my first post.
    I'm trying to populate collection type from XMLType. I was able to populate a table from XMLType but
    couldn't figure out a way to populate the collection type. Here is the description of my problem:
    Object Type:
    CREATE OR REPLACE TYPE DOC_ROWTYPE AS OBJECT
         REFERENCENUMBER VARCHAR2(255),
         REQID NUMBER(12),
         REQDETID NUMBER(12),
         FROMAMOUNT VARCHAR2(31),
         TOAMOUNT VARCHAR2(31),
         TOACCOUNTID NUMBER(12),
         TOACCOUNTNUMBER VARCHAR2(35),
         FROMACCOUNTID NUMBER(12),
         FROMACCOUNTNUMBER VARCHAR2(35),
    Collection Type:
    CREATE OR REPLACE TYPE DOC_TABLETYPE IS TABLE OF DOC_ROWTYPE;
    I have a physical table which is created when I registered a schema.
    A table (Temp_Result) got created with column SYS_NC_ROWINFO$ which is of XMLType.
    As you can see this is only a temporary table which will store the response XML which I want to finally get it to collection type.
    XML to parse:
    <code>
    <TFSResponse>
    <TFS>
    <refNumber>12345</refNumber>
    <reqId>123</reqId>
    <reqDetId>111</reqDetId>
    <fromAmount>20</fromAmount>
    <toAmount>20</toAmount>
    <fromAccount>
    <accountId>22222</id>
    <accountNumber>12345678</number>
    </fromAccount>
    <toAccount>
    <accountId>33333</id>
    <accountNumber>123456789</number>
    </toAccount>
    </TFS>
    .... many TFS Tags
    </TFSResponse>
    </code>
    So each object in the collection is one TFS tag.
    Any advice on how to implement this?

    Does this help
    SQL> CREATE OR REPLACE TYPE ACCOUNT_T as OBJECT (
      2    "accountId"       NUMBER(12),
      3    "accountNumber"   VARCHAR2(35)
      4  )
      5  /
    Type created.
    SQL> show errors
    No errors.
    SQL> --
    SQL> CREATE OR REPLACE TYPE TFS AS OBJECT(
      2     "refNumber"  VARCHAR2(255),
      3     "reqId"      NUMBER(12),
      4     "reqDetId"   NUMBER(12),
      5     "fromAmount" VARCHAR2(31),
      6     "toAmount"   VARCHAR2(31),
      7     "fromAccount" ACCOUNT_T,
      8     "toAccount"   ACCOUNT_T
      9  );
    10  /
    Type created.
    SQL> show errors
    No errors.
    SQL> --
    SQL> CREATE OR REPLACE TYPE TFS_C
      2      as TABLE of TFS
      3  /
    Type created.
    SQL> show errors
    No errors.
    SQL> --
    SQL> CREATE OR REPLACE Type TFS_RESPONSE_T as OBJECT(
      2    "TFSResponse" TFS_C
      3  );
      4  /
    Type created.
    SQL> show errors
    No errors.
    SQL> /
    Type created.
    SQL> CREATE OR REPLACE type CODE_T as OBJECT(
      2    "code" TFS_RESPONSE_T
      3  );
      4  /
    Type created.
    SQL> show errors
    No errors.
    SQL> --
    SQL>
    SQL> with "MY_XML" as
      2  (
      3    select XMLTYPE(
      4  '<code>
      5     <TFSResponse>
      6             <TFS>
      7                     <refNumber>12345</refNumber>
      8                     <reqId>123</reqId>
      9                     <reqDetId>111</reqDetId>
    10                     <fromAmount>20</fromAmount>
    11                     <toAmount>20</toAmount>
    12                     <fromAccount>
    13                             <accountId>22222</accountId>
    14                             <accountNumber>12345678</accountNumber>
    15                     </fromAccount>
    16                     <toAccount>
    17                             <accountId>33333</accountId>
    18                             <accountNumber>123456789</accountNumber>
    19                     </toAccount>
    20             </TFS>
    21             <TFS>
    22                     <refNumber>12346</refNumber>
    23                     <reqId>123</reqId>
    24                     <reqDetId>111</reqDetId>
    25                     <fromAmount>20</fromAmount>
    26                     <toAmount>20</toAmount>
    27                     <fromAccount>
    28                             <accountId>22222</accountId>
    29                             <accountNumber>12345678</accountNumber>
    30                     </fromAccount>
    31                     <toAccount>
    32                             <accountId>33333</accountId>
    33                             <accountNumber>123456789</accountNumber>
    34                     </toAccount>
    35             </TFS>
    36             <TFS>
    37                     <refNumber>12347</refNumber>
    38                     <reqId>123</reqId>
    39                     <reqDetId>111</reqDetId>
    40                     <fromAmount>20</fromAmount>
    41                     <toAmount>20</toAmount>
    42                     <fromAccount>
    43                             <accountId>22222</accountId>
    44                             <accountNumber>12345678</accountNumber>
    45                     </fromAccount>
    46                     <toAccount>
    47                             <accountId>33333</accountId>
    48                             <accountNumber>123456789</accountNumber>
    49                     </toAccount>
    50             </TFS>
    51     </TFSResponse>
    52  </code>') as "XML"
    53    from DUAL
    54  )
    55  select
    56    "TMOBILE"."CODE_T"(
    57      "TMOBILE"."TFS_RESPONSE_T"(
    58        CAST(
    59          MULTISET(
    60            select
    61              "TMOBILE"."TFS"(
    62                "refNumber_000002",
    63                "reqId_000003",
    64                 "reqDetId_000004",
    65                "fromAmount_000005",
    66                "toAmount_000006",
    67                "TMOBILE"."ACCOUNT_T"(
    68                  "accountId_000007",
    69                  "accountNumber_000008"
    70                ),
    71                 "TMOBILE"."ACCOUNT_T"(
    72                  "accountId_000009",
    73                  "accountNumber_000010"
    74                )
    75              )
    76              FROM
    77                XMLTABLE(
    78                  '/TFS'
    79                  passing "TFSResponse_000001"
    80                   COLUMNS
    81                   "refNumber_000002"                  VARCHAR2(255)                       PATH 'refNumber',
    82                   "reqId_000003"                      NUMBER                              PATH 'reqId',
    83                    "reqDetId_000004"                   NUMBER                              PATH 'reqDetId',
    84                   "fromAmount_000005"                 VARCHAR2(31)                        PATH 'fromAmount',
    85                    "toAmount_000006"                   VARCHAR2(31)                        PATH 'toAmount',
    86                     "accountId_000007"                  NUMBER                              PATH 'fromAccount/accountId',
    87                      "accountNumber_000008"              VARCHAR2(35)                        PATH 'fromAccount/accountNumber',
    88                     "accountId_000009"                  NUMBER                              PATH 'toAccount/accountId',
    89                      "accountNumber_000010"              VARCHAR2(35)                        PATH 'toAccount/accountNumber'
    90                )
    91          ) as "TMOBILE"."TFS_C"
    92        )
    93      )
    94    )
    95    FROM MY_XML,
    96      XMLTABLE(
    97        '/'
    98        passing "XML"
    99        COLUMNS
    100              "TFSResponse_000001"                XMLTYPE                             PATH 'code/TFSResponse/TFS'
    101       )
    102
    SQL> /
    CODE_T(TFS_RESPONSE_T(TFS_C(TFS('12345', 123, 111, '20', '20', ACCOUNT_T(22222, '12345678'), ACCOUNT_T(33333, '123456789')), TFS('12346', 123, 111, '20', '20',
    ACCOUNT_T(22222, '12345678'), ACCOUNT_T(33333, '123456789')), TFS('12347', 123, 111, '20', '20',
    ACCOUNT_T(22222, '12345678'), ACCOUNT_T(33333, '123456789')))))
    SQL>

  • SELECT from SYS_REFCURSOR?

    My function is being passed a SYS_REFCURSOR as a parameter. I need to use the values stored within it in one of my SELECT statements. If the REFCURSOR were a Collection I could do something along the lines of:
                 select *
                 from   my_table msg
                          table(cast(my_ref_cursor as my_obj_type)) v
                 where  msg.message_code = v.errorcodeHow can I acheive something similar with a REFCURSOR?
    I am currently using the LOOP/FETCH/EXIT/END LOOP construct to go through each record in the REFCURSOR and then using the ERRORCODE returned by each row in my SELECT statement however this seems a like a poor solution as the same SQL will be executed many times for each record in the REFCURSOR.
    Any ideas as to how I can turn the REFCURSOR into a Collection or a set of values that I can then use in my SELECT statement?

    You can if you go via XML. Consider:
    SQL> CREATE TYPE emp_typ AS OBJECT (
       empno      NUMBER (4),
       ename      VARCHAR (10),
       job        VARCHAR (9),
       mgr        NUMBER (4),
       hiredate   DATE,
       sal        NUMBER (7, 2),
       comm       NUMBER (7, 2),
       deptno     NUMBER (2)
    Type created
    SQL> CREATE TYPE emp_tab AS TABLE OF emp_typ
    Type created
    SQL> CREATE TYPE xmltype_tab AS TABLE OF XMLTYPE
    Type created
    SQL> CREATE OR REPLACE PROCEDURE p (cur IN sys_refcursor)
    AS
       emp_xml     XMLTYPE;
       p_emp_typ   emp_typ;
       mycur       sys_refcursor;
    BEGIN
    /*  Convert the cursor to XML */
       SELECT *
         INTO emp_xml
         FROM TABLE (CAST (XMLSEQUENCE (cur) AS xmltype_tab));
    /* Convert the XML to Object  */
       emp_xml.toobject (p_emp_typ);
    /*  Select from the corresponding Collection */
       OPEN mycur FOR
          SELECT *
            FROM TABLE (CAST (emp_tab (p_emp_typ) AS emp_tab));
       ---  DO_YOUR_STAFF_HERE
       CLOSE mycur;
    END p;
    Procedure created.
    SQL> DECLARE
       cur   sys_refcursor;
    BEGIN
       OPEN cur FOR
          SELECT *
            FROM emp
           WHERE empno = 7369;
    /*  Call procedure with REF cursor */
       p (cur);
       CLOSE cur;
    END;
    PL/SQL procedure successfully completed.Hope this helps.
    Regards
    Michael

  • Problems managing select * from views

    Here a nice sample..
    I have a registered schema and a database with 8000 records.
    Create view first_search_view as
    select extractvalue(XML_CONTENT,'/word/@class') class,
    extractValue(xml_content, '/word/*/lemma/text()') lemma,
    extractValue(xml_content, '/word/*/adverb/form/w/text()') adverb_form,
    extractValue(xml_content, '/word/*/derivation/prebasuf/w/text()') derprebasuf,
    extractValue(xml_content, '/word/*/sense/comword/prebasuf/w/text()') comprebasuf,
    extract(xml_content, '/word/*/sense/collocation/pattern/w/text()').getstringval() colpattern,
    extract(xml_content, '/word/*/idiomExpr/pattern/w/text()') idiompattern,
    extract(xml_content, '/word/*/sense/model/realisation/modpattern/w/text()').getstringval() modpattern,
    extract(xml_content, '/word/*/sense/*/definition/w/text()').getstringval() definition,
    extract(xml_content, '/word/*/sense/description/characteristic/quality/w/text()').getstringval() descquality
    from xml_words
    all ok and infact
    SQL> desc first_search_view;
    Name Null? Type
    CLASS VARCHAR2(4000 CHAR)
    LEMMA VARCHAR2(4000)
    ADVERB_FORM VARCHAR2(4000)
    DERPREBASUF VARCHAR2(4000)
    COMPREBASUF VARCHAR2(4000)
    COLPATTERN VARCHAR2(4000)
    IDIOMPATTERN SYS.XMLTYPE
    MODPATTERN VARCHAR2(4000)
    DEFINITION VARCHAR2(4000)
    DESCQUALITY VARCHAR2(4000)
    But then, when I try to run just:
    Create table first_search as
    select *
    from first_search_view
    The answer is
    ERROR at line 3:
    ORA-19010: Cannot insert XML fragments
    I remove the XMLtype field... I think that it is probably the problem.
    Create table first_search as
    select lemma, adverb_form, DERPREBASUF, COMPREBASUF, COLPATTERN, MODPATTERN, DEFINITION, DESCQUALITY
    from first_search_view
    from first_search_view
    ERROR at line 3:
    ORA-19025: EXTRACTVALUE returns value of only one node
    but if I run the select....
    select lemma, adverb_form, DERPREBASUF, COMPREBASUF, COLPATTERN, MODPATTERN, DEFINITION, DESCQUALITY
    from first_search_view
    It is executed!!!
    There is something wrong.... Really I cannot understand the reason of this.
    Anyone could calrify what could be wrong?
    Stefano

    Stefano, since you did not post the latest xml instance, i have taken the one posted in your previous thread .
    So becuase of which i have to change the XPATH for "idiompattern" column to get some data.
    I too had the same problem as you have posted. But when i added a GetStringVal() method to the expression, it converts it to varchar data type and you are able to create the table. Also you can do GetClobVal if the string has chance to exceed 4000 characters. Later you can convert this to XMLTYPE when ever required.
    declare
      l_xml_data CLOB :=
      '<word class="adjective" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://words.xsd">
      <adjective id="de.a.warm.1">
      <lemma>warm</lemma>
      <morphology>
      <rawData>warm - wärmer - wärmst-</rawData>
      </morphology>
      <sense>
      <adjectiveSubsense>
      <definition>
      <rawData>Warm bedeutet, dass etwas eine relativ hohe Temperatur hat, aber nicht heiß ist.</rawData>
      </definition>
      <translation>
      <rawData>caldo</rawData>
      </translation>
      <example>
      <rawData>Angenehm warme Sommertemperaturen zwischen 24 und 26 Grad werden in der kommenden Woche erwartet. Es ist nicht übermäßig heiß, aber trotzdem warmes Badewetter.</rawData>
      </example>
      </adjectiveSubsense>
      <adjectiveSubsense>
      <definition>
      <rawData>Warm verwendet man für Essen, das gekocht und noch warm (1) ist.</rawData>
      </definition>
      <translation>
      <rawData>caldo</rawData>
      </translation>
      <example>
      <rawData>Das Essen steht auf dem Tisch! Würdest du bitte zu Tisch kommen, solange das Essen noch warm ist!~Ich komm ja gleich, ich muss nur noch schnell das Kapitel fertig lesen!</rawData>
      </example>
      </adjectiveSubsense>
      <insertElement target="field">de.a.warm.1.f1</insertElement>
      <collocation>
      <pattern>
      <rawData>jemdm. ist warm</rawData>
      </pattern>
      <translation>
      <rawData>qualcuno ha caldo</rawData>
      </translation>
      <example>
      <rawData>#Mir #ist #warm. Ich werde meinen Pullover ausziehen!</rawData>
      </example>
      </collocation>
      <collocation>
      <pattern>
      <rawData>etw. ist angenehm warm</rawData>
      </pattern>
      <translation>
      <rawData>qualcosa è bello caldo</rawData>
      </translation>
      <example>
      <rawData>Der Tee ist nicht mehr zu heiß. #Er #ist #angenehm #warm und gerade richtig zum Trinken.</rawData>
      </example>
      </collocation>
      <collocation>
      <pattern>
      <rawData>es ist warm</rawData>
      </pattern>
      <translation>
      <rawData>fa caldo</rawData>
      </translation>
      <example>
      <rawData>Kaum scheint nach dem Sommergewitter wieder die Sonne, #ist #es sofort wieder #warm.</rawData>
      </example>
      </collocation>
      <collocation>
      <pattern>
      <rawData>ein warmes Bad nehmen</rawData>
      </pattern>
      <translation>
      <rawData>farsi un bagno caldo</rawData>
      </translation>
      <example>
      <rawData>Ich bin völlig durchnässt und erfroren nach Hause gekommen. Dann #habe ich #ein #warmes #Bad #genommen, um mich wieder aufzuwärmen.</rawData>
      </example>
      </collocation>
      <collocation>
      <pattern>
      <rawData>warm essen</rawData>
      </pattern>
      <translation>
      <rawData>fare un pasto caldo</rawData>
      </translation>
      <example>
      <rawData>In diesem Restaurant ist die Küche bis 23 Uhr geöffnet und man kann #warm #essen.</rawData>
      </example>
      </collocation>
      <collocation>
      <pattern>
      <rawData>etw. warm stellen</rawData>
      </pattern>
      <translation>
      <rawData>mettere in caldo qualcosa</rawData>
      </translation>
      <example>
      <rawData>Herr Tieser hat sich zum Abendessen verspätet und seine Familie hat mit dem Essen nicht auf ihn gewartet. Sie #haben ihm #das #Risotto jedoch #warm #gestellt.</rawData>
      </example>
      </collocation>
      <collocation>
      <pattern>
      <rawData>warmes Wasser</rawData>
      </pattern>
      <translation>
      <rawData>acqua calda</rawData>
      </translation>
      <example>
      <rawData>Die Hausverwaltung weist die Parteien darauf hin, dass wegen Reparaturarbeiten morgen zwischen 9 und 12 Uhr #das #warme #Wasser abgestellt wird.</rawData>
      </example>
      </collocation>
      <collocation>
      <pattern>
      <rawData>warme Tage, warme Luft, ein warmes Klima, ein warmer Winter, ein warmer Sommer ...</rawData>
      </pattern>
      <translation>
      <rawData>giornate calde, aria calda, un clima caldo, un inverno caldo, un''esate calda ...</rawData>
      </translation>
      <example>
      <rawData>Ich habe seit drei Tagen Kopfschmerzen. Vermutlich liegt das am Föhn und #dieser #warmen #Luft, die ich nicht vertrage.</rawData>
      </example>
      </collocation>
      <collocation>
      <pattern>
      <rawData>eine warme Mahlzeit, enie warme Speise, ein warmes Essen ...</rawData>
      </pattern>
      <translation>
      <rawData>un pasto caldo, un piatto caldo, un pasto caldo ...</rawData>
      </translation>
      <example>
      <rawData>Nachdem ich in den letzten Tagen immer nur Salat gegessen habe, freue ich mich heute wieder darauf, #eine #warme #Speise zu genießen.</rawData>
      </example>
      </collocation>
      <collocation>
      <pattern>
      <rawData>warme und kalte Küche</rawData>
      </pattern>
      <translation>
      <rawData>piatti caldi e freddi</rawData>
      </translation>
      <example>
      <rawData>Die Cafeteria der Uni bietet durchgehend #warme #Küche an.</rawData>
      </example>
      </collocation>
      </sense>
      <sense>
      <adjectiveSubsense>
      <definition>
      <rawData>Warm bedeutet, dass etwas so ist, dass es vor Kälte schützt.</rawData>
      </definition>
      <translation>
      <rawData>caldo</rawData>
      </translation>
      <example>
      <rawData>Die Schuhverkäuferin preist die neue Ware an: Die gefütterten Winterschuhe sind sehr warm. Sie werden nie wieder kalte Zehen bekommen!</rawData>
      </example>
      </adjectiveSubsense>
      <insertElement target="field">de.a.warm.1.f2</insertElement>
      <collocation>
      <pattern>
      <rawData>etw. hält warm</rawData>
      </pattern>
      <translation>
      <rawData>qualcosa tiene caldo</rawData>
      </translation>
      <example>
      <rawData>Die selbst gestrickten Socken sind zwar kratzig, aber #sie #halten ausgesprochen #warm!</rawData>
      </example>
      </collocation>
      <collocation>
      <pattern>
      <rawData>sich warm anziehen</rawData>
      </pattern>
      <translation>
      <rawData>mettersi indumenti caldi~coprirsi bene</rawData>
      </translation>
      <example>
      <rawData>#Zieh #dich #warm an, wenn du bei dem Sturm hinausgehst, sonst verkühlst du dich noch!</rawData>
      </example>
      </collocation>
      <collocation>
      <pattern>
      <rawData>sich warm zudecken</rawData>
      </pattern>
      <translation>
      <rawData>coprirsi bene</rawData>
      </translation>
      <example>
      <rawData>Nach der Gutenachtgeschichte macht Vati das Licht aus, #deckt #mich #warm #zu und wünscht mir süße Träume.</rawData>
      </example>
      </collocation>
      <collocation>
      <pattern>
      <rawData>warm angezogen sein</rawData>
      </pattern>
      <translation>
      <rawData>indossare vestiti caldi, essere coperto bene</rawData>
      </translation>
      <example>
      <rawData>Bei diesen arktischen Temperaturen ist es wichtig, dass man #warm #angezogen #ist, wenn man das Haus verlässt.</rawData>
      </example>
      </collocation>
      <collocation>
      <pattern>
      <rawData>warm eingepackt sein</rawData>
      </pattern>
      <translation>
      <rawData>essere imbacuccato, essere coperto bene</rawData>
      </translation>
      <example>
      <rawData>Die Kinder spielen auf dem Kinderspielplatz. Sie #sind wegen des kalten Wetters sehr #warm #eingepackt und haben Mütze, Schal und Handschuhe an.</rawData>
      </example>
      </collocation>
      <collocation>
      <pattern>
      <rawData>warme Kleidung</rawData>
      </pattern>
      <translation>
      <rawData>indumenti caldi</rawData>
      </translation>
      <example>
      <rawData>Ab Jänner ist die #warme Winterkleidung bereits im Ausverkauf und die Frühlingsmode erscheint in den Schaufenstern.</rawData>
      </example>
      </collocation>
      </sense>
      <sense>
      <adjectiveSubsense>
      <definition>
      <rawData>Warm bedeutet freundlich und dass es von Herzen kommt.</rawData>
      </definition>
      <translation>
      <rawData>caldo~caloroso</rawData>
      </translation>
      <example>
      <rawData>Frau Hanse ist eine warme Frau. Sie interessiert sich immer ehrlich für das Wohlbefinden ihrer Nachbarn und ihr Mitgefühl kommt von Herzen.</rawData>
      </example>
      </adjectiveSubsense>
      <insertElement target="field">de.a.warm.1.f3</insertElement>
      <collocation>
      <pattern>
      <rawData>ein warmes Herz</rawData>
      </pattern>
      <translation>
      <rawData>un cuore caldo</rawData>
      </translation>
      <example>
      <rawData>Auf Anne kann man immer zählen. Sie hat #ein #warmes #Herz, hört einem immer zu und ist bei jedem Spass dabei. Sie ist eine gute Freundin.</rawData>
      </example>
      </collocation>
      <collocation>
      <pattern>
      <rawData>warme Worte</rawData>
      </pattern>
      <translation>
      <rawData>parole calorose</rawData>
      </translation>
      <example>
      <rawData>#Die #warmen, verständnisvollen #Worte taten meiner Seele gut und munterten mich wieder auf.</rawData>
      </example>
      </collocation>
      <collocation>
      <pattern>
      <rawData>ein warmer Händedruck</rawData>
      </pattern>
      <translation>
      <rawData>una calorosa stretta di mano</rawData>
      </translation>
      <example>
      <rawData>#Mit #einem #warmen #Händedruck verabschiedeten sich die beiden Freunde herzlich voneinander.</rawData>
      </example>
      </collocation>
      </sense>
      <sense>
      <adjectiveSubsense>
      <definition>
      <rawData>Warm verwendet man für Farben und Licht, die kräftig sind und warm (1a) wirken und die eine angenehme Antmosphäre verbreiten.</rawData>
      </definition>
      <translation>
      <rawData>caldo</rawData>
      </translation>
      <example>
      <rawData>Die Farbpalette wird in kalte und warme Farben eingeteilt. Rot und orange sind zum Beispiel warme Farben.</rawData>
      </example>
      </adjectiveSubsense>
      <insertElement target="field">de.a.warm.1.f4</insertElement>
      <collocation>
      <pattern>
      <rawData>etw. spendet warmes Licht</rawData>
      </pattern>
      <translation>
      <rawData>qalcosa emette una luce calda</rawData>
      </translation>
      <example>
      <rawData>#Die #flackernde #Kerze #spendet #warmes #Licht und taucht den Raum in eine behagliche Atmosphäre.</rawData>
      </example>
      </collocation>
      <collocation>
      <pattern>
      <rawData>warme Farben</rawData>
      </pattern>
      <translation>
      <rawData>colori caldi</rawData>
      </translation>
      <example>
      <rawData>Der Innenarchitekt empfiehlt dem jungen Ehepaar, #warme #Farben für das Kinderzimmer zu wählen, da sie ein Bedürfnis nach Harmonie wecken.</rawData>
      </example>
      </collocation>
      <collocation>
      <pattern>
      <rawData>ein warmes Braun, ein warmes Rot ...</rawData>
      </pattern>
      <translation>
      <rawData>un marrone caldo, un rosso caldo ...</rawData>
      </translation>
      <example>
      <rawData>Der Sonnenuntergang war sehr romantisch. #Das #warme #Rot der Sonne hat sich im Meer gespiegelt. Schließlich ist sie wie ein großer Ball am Horizont verschwunden.</rawData>
      </example>
      </collocation>
      </sense>
      <sense>
      <adjectiveSubsense>
      <definition>
      <rawData>Warm bedeutet, dass die Kosten für die Heizung bei der Miete schon dabei ist.</rawData>
      </definition>
      <translation>
      <rawData>riscaldamento incluso</rawData>
      </translation>
      <example>
      <rawData>Roland erkundigt sich beim Vermieter über die Mietkosten. Dieser erklärt ihm, dass die Wohnung 800 Euro im Monat warm kostet.</rawData>
      </example>
      </adjectiveSubsense>
      <insertElement target="field">de.a.warm.1.f5</insertElement>
      <collocation>
      <pattern>
      <rawData>das Zimmer, die Wohnung ... kostet x Euro warm</rawData>
      </pattern>
      <translation>
      <rawData>la camera, l''appartamento ... costa x euro riscaldamento incluso</rawData>
      </translation>
      <example>
      <rawData>Ich habe ein neues Zimmer gemietet. Die Kosten für die Heizung sind schon inklusive. Es kostet also 300 Euro warm.</rawData>
      </example>
      </collocation>
      </sense>
      <derivation>
      <prebasuf>
      <rawData>auf_wärm_en</rawData>
      </prebasuf>
      <translation>
      <rawData>(ri)scaldare</rawData>
      </translation>
      </derivation>
      <derivation>
      <prebasuf>
      <rawData>die Er_wärm_ung</rawData>
      </prebasuf>
      <translation>
      <rawData>il riscaldamento</rawData>
      </translation>
      </derivation>
      <derivation>
      <prebasuf>
      <rawData>er_wärm_en</rawData>
      </prebasuf>
      <translation>
      <rawData>(ri)scaldare, appassionare</rawData>
      </translation>
      </derivation>
      <derivation>
      <prebasuf>
      <rawData>vor_wärm_en</rawData>
      </prebasuf>
      <translation>
      <rawData>preriscaldare</rawData>
      </translation>
      </derivation>
      <derivation>
      <prebasuf>
      <rawData>die Wärme</rawData>
      </prebasuf>
      <translation>
      <rawData>il caldo, il calore</rawData>
      </translation>
      </derivation>
      <derivation>
      <prebasuf>
      <rawData>wärmen</rawData>
      </prebasuf>
      <translation>
      <rawData>(ri)scaldare</rawData>
      </translation>
      </derivation>
      <idiomExpr>
      <pattern>
      <rawData>sich warm machen</rawData>
      </pattern>
      <explanationDE>
      <rawData>vor dem Sport oder vor einem Wettbewerb Gymnastik machen, um die Muskeln aufzulockern</rawData>
      </explanationDE>
      <explanationIT>
      <rawData>fare ginnastica per scigliere i muscoli prima di una gara sportiva</rawData>
      </explanationIT>
      <translation>
      <rawData>riscaldarsi, fare riscaldamento</rawData>
      </translation>
      <example>
      <rawData>In einer halben Stunde beginnt der Wettkampf. Davor muss ich #mich noch #warm #machen.</rawData>
      </example>
      </idiomExpr>
      <idiomExpr>
      <pattern>
      <rawData>sich warm reden</rawData>
      </pattern>
      <explanationDE>
      <rawData>beim Reden seine Befangenheit, Zurückhaltung verlieren</rawData>
      </explanationDE>
      <explanationIT>
      <rawData>vincere la timidezza e la riservatezza e iniziare a parlare con scorrevolezza</rawData>
      </explanationIT>
      <translation>
      <rawData>sciogliersi, sciogliere la lingua</rawData>
      </translation>
      <example>
      <rawData>Mein Vortrag war sehr gut. Nach nur fünf Minuten #hatte ich #mich #warm #geredet und dann habe ich über eine halbe Stunde fließend geredet.</rawData>
      </example>
      </idiomExpr>
      <idiomExpr>
      <pattern>
      <rawData>mit jemdm./etw. (nicht) warm werden</rawData>
      </pattern>
      <comment>
      <rawData>umgangssprachlich</rawData>
      </comment>
      <explanationDE>
      <rawData>mit jemdm./etw. (nicht) vertraut werden und (nicht) sympathisch finden</rawData>
      </explanationDE>
      <explanationIT>
      <rawData>(non) acquisire familiarità con qualcuno/qualcosa</rawData>
      </explanationIT>
      <translation>
      <rawData>(non) entrare in confidenza con qualcuno/(non) prendere confidenza con qualcosa</rawData>
      </translation>
      <example>
      <rawData>Zu Claudia habe ich noch immer kein herzliches Verhältnis gefunden. Ich #werde einfach #nicht #warm #mit #ihr.</rawData>
      </example>
      </idiomExpr>
      </adjective>
      </word>';
    begin
      insert into xml_table values(1, xmltype(l_xml_data));
    end;
    Create or replace view first_search_view as
    select extractvalue(xml_data,'/word/@class') class,
      extractValue(xml_data, '/word/*/lemma/text()') lemma,
      extractValue(xml_data, '/word/*/adverb/form/w/text()') adverb_form,
      extractValue(xml_data, '/word/*/derivation/prebasuf/w/text()') derprebasuf,
      extractValue(xml_data, '/word/*/sense/comword/prebasuf/w/text()') comprebasuf,
      extract(xml_data, '/word/*/sense/collocation/pattern/w/text()').getstringval() colpattern,
    extract(xml_data, '/word/*/idiomExpr/pattern').GetClobVal() idiompattern,
      extract(xml_data, '/word/*/sense/model/realisation/modpattern/w/text()').getstringval() modpattern,
      extract(xml_data, '/word/*/sense/*/definition/w/text()').getstringval() definition,
      extract(xml_data, '/word/*/sense/description/characteristic/quality/w/text()').getstringval() descquality
    from xml_table
    create table test_xml_table
    as
    select * from first_Search_view
    SQL> desc first_search_View
    Name                                                  Null?    Type
    CLASS                                                          VARCHAR2(4000)
    LEMMA                                                          VARCHAR2(4000)
    ADVERB_FORM                                                    VARCHAR2(4000)
    DERPREBASUF                                                    VARCHAR2(4000)
    COMPREBASUF                                                    VARCHAR2(4000)
    COLPATTERN                                                     VARCHAR2(4000)
    IDIOMPATTERN                                                   CLOB
    MODPATTERN                                                     VARCHAR2(4000)
    DEFINITION                                                     VARCHAR2(4000)
    DESCQUALITY                                                    VARCHAR2(4000)
    SQL> desc test_xml_table
    Name                                                  Null?    Type
    CLASS                                                          VARCHAR2(4000)
    LEMMA                                                          VARCHAR2(4000)
    ADVERB_FORM                                                    VARCHAR2(4000)
    DERPREBASUF                                                    VARCHAR2(4000)
    COMPREBASUF                                                    VARCHAR2(4000)
    COLPATTERN                                                     VARCHAR2(4000)
    IDIOMPATTERN                                                   CLOB
    MODPATTERN                                                     VARCHAR2(4000)
    DEFINITION                                                     VARCHAR2(4000)
    DESCQUALITY                                                    VARCHAR2(4000)
    SQL> set linesize 200
    SQL> column class format a20
    SQL> column idiompattern format a70
    SQL>
    SQL> select class,  idiompattern from test_xml_table
      2  /
    CLASS                IDIOMPATTERN
    adjective            <pattern>
                           <rawData>sich warm machen</rawData>
                         </pattern>
                         <pattern>
                           <rawData>sich warm reden</rawData>
                         </pattern>
                         <pattern>
                           <rawData>mit jemdm./etw. (nicht) warm werden</rawData>
                         </pattern>
    SQL>

  • Reading element from XMLTYPE column with repeated

    I have below data in my XML column and want to read all the values of <name>
    <data>
    <name>aaa</name>
    <name>bbb</name>
    <name>ccc</name>
    </data>
    Please suggest.
    Regards.

    SQL> SET LINES 100
    SQL> DESC XMLTABLE
    Name                                                  Null?    Type
    XML1                                                           XMLTYPE
    ID                                                             NUMBER
    SQL> SET LINES 10000
    SQL> COLUMN XML1 FORMAT A100
    SQL> SELECT * FROM XMLTABLE;
    XML1                                                                                                      ID
    <data>                                                                                                     1
      <name>aaa</name>
      <name>bbb</name>
      <name>ccc</name>
    </data>
    SQL> SELECT ID, extract(XML1,'/data/name/text()') EXTRACTED FROM XMLTABLE
      2  /
            ID EXTRACTED
             1 aaabbbccc
    SQL> Or
    SQL> ed
    Wrote file afiedt.buf
      1  SELECT
      2     ID,
      3     substr( trim(replace(replace (replace(replace (XML1,'<data>', ' '), '</data>', ' '), '</name>', ' '), '<name>', ', ')), 3) EXTRACTED
      4  FROM
      5*    XMLTABLE
    SQL> /
            ID EXTRACTED
             1  aaa
               , bbb
               , ccc

  • Selection from a Maintenance View

    Hi,
        I have to fetch data from a view, unfotunately that view is a mainteance view. Is there any other way to select/fetch data from that view in my report program ?
    Regards,
    Bharath Mohan B

    Hi
    U cannot access the data from maintanence view.
    Only projection and database view can be used in ABAP code.
    If u want to access the Data from more the one table , Create the DATABASE VIEW and use this view in ur program.
    For example : UR Database view name is Ztest
    in ur program
    table Ztest.
    select * from Ztest ***************
    *******************UR Business Logic
    <b>Reward if useful</b>

  • URGENT : select from table statement in ABAP OO

    Hi all,
    I am an absolute ABAP OO beginner and need some quick help from an expert. How can I make a selection from an existing table (eg MARA) in an BADI which is programmed according to ABAP OO principles.
    In the old ABAP school you could make a TABLES statement at the beginning and the do a SELECT¨* FROM but this does not work in ABAP OO.
    How should i define such simple selections from existing tables. Anyone ?
    Thanks a lot,
    Eric Hassenberg

    *define internal table
    data: i_mara like standard table of mara.
    *select to this table
    select * from mara into table i_mara.
    Also you have to define work area for this internal table in order to use it.
    data:w_mara like line of i_mara.

  • Select from v$sql_plan in a procedure

    Hi
    I''m attempting to save plans (from V$SQL_PLAN) into a table using a procedure in schema APPS, but keep getting missing table error,
    PL/SQL: ORA-00942: table or view does not existI then granted an explicit SELECT to APPS on the V$SQL_PLAN table from a schema with
    a DBA role, but still get the same error when compiling the procedure.
    SQL> create table gl_imp_post_plans as ( select * from v$sql_plan where rownum < 1);
    Table created.
    SQL> select count(*) from v$sql_plan;
      COUNT(*)
         13506
    SQL> create or replace procedure Ins_Plan_from_Dictionary as
      2 
      3    begin
      4      insert into GL_Imp_Post_Plans
      5      select  sqo.*
      6      from    v$sql_plan sqo
      7      where  (sqo.sql_id) not in (select distinct gipi.SQL_ID
      8                                  from   GL_Imp_Post_Plans gipi)
      9      and    (sqo.sql_id) in     (select distinct
    10                                         sqi.sql_id
    11                                  from   v$sql_plan sqi
    12                                  where  sqi.object_owner = 'APPS'
    13                                  and    sqi.object_name  in ('GL_BALANCES','GL_DAILY_BALANCES','GL_JE_LINES') );
    14      commit;
    15 
    16 
    17      exception
    18        when others then
    19          rollback;
    20  --        sysao_util.Message ('O', 'Error ' || sqlerrm);
    21 
    22  end Ins_Plan_from_Dictionary;
    23  /
    Warning: Procedure created with compilation errors.
    SQL> show err
    Errors for PROCEDURE INS_PLAN_FROM_DICTIONARY:
    LINE/COL ERROR
    4/5      PL/SQL: SQL Statement ignored
    11/40    PL/SQL: ORA-00942: table or view does not exist
    SQL>
    SQL> l 11
    11*                                 from   v$sql_plan sqiThe same error occurs when I attempt to select from GV$SQL_PLAN or DBA_HIST_SQL_PLAN.
    Could anybody suggest how I can persist the rows into a table using a procedure?
    thanks

    thanks, yes this works:
    create or replace procedure Ins_Plan_from_Dictionary as
      begin
        execute immediate 'begin
                            insert into GL_Imp_Post_Plans
                            select  sqo.*
                            from    v$sql_plan sqo
                            where  (sqo.sql_id) not in (select distinct gipi.SQL_ID
                                                        from   GL_Imp_Post_Plans gipi)
                            and    (sqo.sql_id) in     (select distinct
                                                               sqi.sql_id
                                                        from   v$sql_plan sqi
                                                        where  sqi.object_owner = ''APPS''
                                                        and    sqi.object_name  in (''GL_BALANCES'',''GL_DAILY_BALANCES'',''GL_JE_LINES'') );
                            commit;
                           end;';
        exception
          when others then
            rollback;
    --        sysao_util.Message ('O', 'Error ' || sqlerrm);
    end Ins_Plan_from_Dictionary;
    /

Maybe you are looking for

  • Is it possible to customize photostream?

    I'd like to be able to have photos from iPhone go to my computer, but I sometimes scan things or otherwise add stuff to my iMac's iPhoto that I don't need on my iPhone. Is it possible to put a one-way e-valve in photostream between the two?

  • Seek to a point in video?

    I'm trying to figure out a way to use jQuery to seek to a point in an HTML5 video. This tutorial actually gives an example of how to do it using JavaScript, but I'm not sure if it will work in Edge Animate or not. It's not really jQuery, is it? Has a

  • Organize photos within events

    I'm using iPhoto 09 on Snow Leopard and I love the whole 'events' feature, it's great, but when I'm actually looking through an event, let's say "Colorado 09", the pictures were imported in a different order than I wanted them. How do I re-organize t

  • Method of Synchronization between XE and Enterprise (Offline)

    Hi, We have two DB servers hosted in two locations which has 10g XE and 10g Enterprise. These sites will be connected in dial-up lines only when needed to synchronize (from XE to Enterprise). Please can anyone tell me what is the best method we can d

  • Crystal Report XI: Parameter Field Dynamic Default Values Limitation?

    Post Author: Elie_123 CA Forum: General Hi,Using Crystal Report XI.I have a parameter field with Dynamic values that Queries the company field of an SQL Database.I have around 3500 companies in my DB. But when running my report (Using Crystal), only