sys_xmlgen

Hi all

I am trying to learn Oracle sys_xmlgen

I use the Oracle HR schema

Here is the Oracle version

Connected to:

Oracle Database 11 g Enterprise Edition Release 11.2.0.1.0 - 64 bit Production

With partitioning, OLAP, Data Mining and Real Application Testing options

create or replace type employee_map_type as object)

employe_id number (6).

first name varchar2 (20).

VARCHAR2 (25) last_name,.

e-mail varchar2 (25).

Phone_Number varchar2 (20).

hire_date date,

job_id varchar2 (10),

number (8.2) of salary.

commission_pct number (2.2).

manager_id number (6).

department_id number 4

);

It is created successfully.

create or replace procedure employee_xml (emp_id in number)

as

xml_employee xmltype.

Start

Select

sys_xmlgen

(employee_map_type

(e.employee_id,

e.first_name,

Select,

e.email,

e.Phone_Number,

e.hire_date,

e.job_id,

e.salary,

e.commission_pct,

e.manager_id,

e.department_id)

) in xml_employee

of hr.employees

where e.employee_id = emp_id;

dbms_output.put_line (xml_employee.getclobval ());

end;

I got the error

EMPLOYEE_XML update procedure

Errors: Newspaper the compiler check

If I try to run the sql only

SQL > select

2 sys_xmlgen

3 (employee_map_type

4 (e.employee_id,

e.first_name 5,.

6. Select,

e.email 7,.

e.phone_number 8,.

e.hire_date 9,.

e.job_id 10,

e.salary 11,

e.commission_pct 12,

e.manager_id 13,

14 e.department_id)

(15) - in xml_employee

16 hr.employees;

e.department_id)

*

ERROR on line 14:

ORA-00904: "E". "" Department_id ": invalid identifier

I am not able to understand, department_id column is there in the employees table, as well as in the employee_map_type object.

Please help me.

Thank you

Hi 956650

You forgot alias 'e '.

"of hr.employees e.

Tags: Database

Similar Questions

  • Using functions Oracle XML - sys_xmlgen and dbms_xmlgen

    I am new to Oracle 10 g and XML. I've been reading and practice with examples and understand a point of what is happening.

    Here's my problem: I have a student athlete who can have many rewards. How can I get several scholarships to work with sys_xmlgen or dbms_xmlgen? Or is this even possible?
    The data is stored in tables, XMLType.
    This problem uses several tables as a sport table, table of students and a table of prices.

    There is an example of output of a student with multiple tags within the tag of the student price:

    < student schoolSidNumber = '999-12-6745' fulltimeEnrollmentTermHere = 'S1' fulltimeEnrollmentYearHere = "2003" action = "none" firstName = "Import" lastName = 'Test' recruited 'M' = sex = 'Y' comments = date of birth "Created from the process of import." = '1971-09-12' Address1 = "123 University Drive" city = 'University City' State 'IN' = >
    < guardianName warden = "Mr. & amp; Ms. Import Test' homeFlag = 'Y' Address1 = "123 Avenue House" city = 'Brazil' state 'IN' = / >
    < year value "2008" action = 'none' = >
    < sport sportCode = "MBB" initialCounterFlag = 'Y' action = 'save' / >
    < aidLimits sportCode = "MBB" grantInAidAmt = "10000" costAttendAmt = "11000" / >
    < price action = 'save' saAidId = '0' fundCode = 'ATHLETES' sportCode = "MBB" rolloverFlag = "N" awardPeriod = "FY" awardAmount = "5000" awardDate = "2005-08-13" / >
    < price action = 'save' saAidId = '0' fundCode = "INST" sportCode = "MBB" rolloverFlag = "N" awardPeriod = "FY" awardAmount = "2000" awardDate = "2005-08-13" / >
    < continuingEligibility classDescription = "FRESHMAN" degreeDeclareDate = "" academicIneligible = "N" degreeReqHours = '120' degreeId = '1' saCumulativeGpa = "3,397" "
    totalDegreeHours = "26" / >
    < term action = 'save' termCode = 'S1' hoursAttempted = '12' hoursEarned = '12' gpa = "4.0" fullTimeFlag = "Y" / >
    < term action = 'save' termCode = 'S2' hoursAttempted = hoursEarned "14" = "14" gpa = '3.0' fullTimeFlag = 'Y' / >
    < / year >
    < original acceptedDate = "2002-04-01" >
    < testScore p1Score = '400' p2Score = '400' testCode = "S" testDate = "1999-05-31" / >
    < / original >
    < / student >

    I know I could do with dbms_output.put_line tags, but I want to take full advantage of Oracle XML.
    Any help would be greatly appreciated.

    Published by: user9507990 on August 5, 2009 08:37

    OK, I probably messed up a bit with joins (got duplicates), but here's the idea:

    SELECT
    xmlelement("students",
     xmlagg(
      xmlelement("student",
                 xmlattributes(stu.student_id as "studentId",
                               stu.student_last_name as "lastName",
                               stu.student_first_name as "firstName"),
       xmlagg(
        xmlelement("sport",
                   xmlattributes(spo.sport_actc_code as "sportCode",
                                 spo.sport_term_code as "termCode")
        )
       ),
       xmlagg(
        xmlelement("award",
                   xmlattributes(awd.award_fund_code as "fundCode",
                                 awd.award_accept_amt as "awardAmount",
                                 to_char(awd.award_accept_date, 'YYYY-MM-DD') as "awardDate")
        )
       )
      )
     )
    )
    FROM students stu
         JOIN sports spo ON spo.sport_pidm = stu.student_pidm
         JOIN terms ter ON ter.term_code = spo.sport_term_code
         JOIN awards awd ON awd.award_aidy_code = ter.term_aidy_code AND awd.award_pidm = stu.student_pidm
    GROUP BY stu.student_id, stu.student_last_name, stu.student_first_name
    ORDER BY stu.student_id;
    

    The query uses the XMLELEMENT and XMLAGG to build the structure:
    The root element is 'students', to which we add several child nodes of "student".
    XMLATTRIBUTES is used to set the attributes of an element.

    Another solution would be to produce a "gross" in canonical format (...) xml document Oracle from using DBMS_XMLGEN this query:

    SELECT stu.student_id, stu.student_last_name, stu.student_first_name,
           spo.sport_actc_code, spo.sport_term_code,
           awd.award_fund_code, awd.award_accept_amt, to_char(awd.award_accept_date, 'YYYY-MM-DD') award_accept_date
    FROM students stu
         JOIN sports spo ON spo.sport_pidm = stu.student_pidm
         JOIN terms ter ON ter.term_code = spo.sport_term_code
         JOIN awards awd ON awd.award_aidy_code = ter.term_aidy_code AND awd.award_pidm = stu.student_pidm
    ORDER BY stu.student_id, spo.sport_actc_code, awd.award_fund_code;
    

    And then apply an XSL transformation to achieve the desired result.

    Hope that helps.

    Published by: odie_63 on August 6, 2009 14:44

  • Generation of an element of an Instance of data type defined by the user

    Hi all

    I am trying to generate an element with several attributes xml, (I don't want to use builtin xmlattributes )

    Script common and produces xml is,

    -lower table departments

    create table services (department_id number (2))

    , department_name varchar2 (14)

    ) ;

    insert into departments values (10, 'Blue');

    insert into a values (20, 'Red') departments;

    -drop table employees

    create the table employees (employee_id number 4

    , last_name varchar2 (10)

    (, number (2)) department_id;

    insert into employees values ("1,'Ram gupta", 10);

    insert into employees values (2, 'Pan Yadav', 10);

    insert into employees values ("3, ' Asu Jena", 20);

    insert into values employed (4 'Viv Pandey', 20);

    CREATE or REPLACE TYPE emp_t AS OBJECT ("@EMPNO" number 4,

    ENAME VARCHAR2 (10));

    /

    CREATE or REPLACE TYPE emplist_t AS TABLE OF THE emp_t;

    /

    CREATE or REPLACE TYPE AS OBJECT dept_t ("@DEPTNO" NUMBER (2),)

    DNAME VARCHAR2 (14).

    EMP_LIST emplist_t

    );

    /

    CREATE or REPLACE TYPE deptxml AS TABLE OF THE dept_t;

    -The query for XMl,.

    SELECT

    dept_t (department_id,

    department_name, CAST ((SELECT employe_id, last_name MULTISET

    E EMPLOYEES

    WHERE e.department_id = d.department_id)

    AS emplist_t)

    )

    AS deptxml

    DEPARTMENTS d

    WHERE d.department_id = 10;

    XML product

    <? XML version = "1.0"? >

    -Department < and >

    -< DEPT_T DEPTNO = "10" >

    Blue < DNAME > < / DNAME >

    -< EMP_LIST >

    -< EMP_T EMPNO = "1" >

    < ENAME > Ram gupta < / ENAME >

    < / EMP_T >

    -< EMP_T EMPNO = "2" >

    Yannick Pan < ENAME > < / ENAME >

    < / EMP_T >

    < / EMP_LIST >

    < / DEPT_T >

    < / Department >

    Required XML code is...

    <? XML version = "1.0"? >

    -Department < and >

    -< DEPT_T DEPTNO = "10" >

    Blue < DNAME > < / DNAME >

    -< EMP_LIST >

    -< EMP_T EMPNO, ENAME = '1' = 'Ram gupta' > < / EMP_T >

    -< EMP_T EMPNO = '2' = ENAME "Pan yannick ' > < / EMP_T >

    < / EMP_LIST >

    < / DEPT_T >

    < / Department >

    Please kindly suggest me the script for this XML.

    SQL> CREATE OR REPLACE TYPE emp_t AS OBJECT ("@EMPNO" NUMBER(4),  2                                          "@ENAME" VARCHAR2(10))  3  /
    Type created.
    SQL> CREATE OR REPLACE TYPE emplist_t AS TABLE OF emp_t  2  /
    Type created.
    SQL> CREATE OR REPLACE TYPE dept_t AS OBJECT ("@DEPTNO" NUMBER(2),  2                                          DNAME VARCHAR2(14),  3                                          EMP_LIST emplist_t  4                                          )  5  /
    Type created.
    SQL> CREATE OR REPLACE TYPE deptxml AS TABLE OF dept_t  2  /
    Type created.
    SQL> select sys_xmlgen  2        (  3          deptxml  4          (  5            dept_t  6            (  7                department_id  8              , department_name  9              , cast 10                ( 11                    multiset 12                    ( 13                      select employee_id 14                            , last_name 15                        from employees e 16                        where e.department_id = d.department_id 17                    ) as emplist_t 18                ) 19            ) 20          ) 21        , sys.xmlgenformattype.createformat('Department') 22        ) as deptxml 23    from departments d 24  where d.department_id = 10;
    DEPTXML--------------------------------------------------------------------------   Blue         
    
    SQL>
    
  • How to create indexes on the ordered collection of XMLTYPE table?

    I use Oracle 11.2.0.2.

    Basically, my XML documents have a 3-level hierarchy:

    event

    + - action [1: n]

    + - param [1: n]

    I try to create indexes on the tables of the orderly collection, but cannot get the right syntax...

    I created a table with an XMLType object-relational column:

    CREATE TABLE T_C_RMP_MNTRNG_XML_FULL_IL4 (
      MESSAGE_ID NUMBER(22,0) NOT NULL ENABLE,
      XML_EVAL_ID NUMBER(22,0),
      VIN7 VARCHAR2(7 BYTE),
      FLEET_ID VARCHAR2(50 BYTE),
      CSC_SW_VERSION VARCHAR2(100 BYTE),
      RECEIVED DATE,
      XML_CONTENT SYS.XMLTYPE ,
      DWH_LM_TS_UTC DATE NOT NULL ENABLE,
      CONSTRAINT PK_C_RMP_MNTRNG_XML_FULL_IL4 PRIMARY KEY (MESSAGE_ID)
    ) NOLOGGING TABLESPACE CATALOG
    VARRAY "XML_CONTENT"."XMLDATA"."action" STORE AS TABLE "T_OR_MON_ACTION" (
      NOLOGGING TABLESPACE "CATALOG"
      VARRAY "param" STORE AS TABLE "T_OR_MON_ACTION_PARAM" (
      NOLOGGING TABLESPACE "CATALOG"
      ) RETURN AS LOCATOR
    ) RETURN AS LOCATOR
    XMLTYPE XML_CONTENT STORE AS OBJECT RELATIONAL XMLSCHEMA "http://mydomain.com/cs.xsd" ELEMENT "monitoring";
    
    
    
    
    

    I execute the SELECT statement:

    SELECT EVENT_ID, ACTION_SUB_ID, MESSAGE_ID, ACTION_TYPE, UNIXTS_TO_DATE(ACTION_TIMESTAMP) ACTION_TIMESTAMP
    FROM T_C_RMP_MNTRNG_XML_FULL_IL4, 
    XMLTABLE( 
      'for $i1 in /monitoring , 
      $i2 in $i1/action            
      return element r {              
      $i1/eventId,              
      $i2            
      }' 
      PASSING XML_CONTENT COLUMNS 
      EVENT_ID VARCHAR(40) PATH 'eventId', 
      ACTION_SUB_ID INTEGER PATH 'action/actionSubId', 
      ACTION_TYPE VARCHAR2(100) PATH 'action/type', 
      ACTION_TIMESTAMP NUMBER(13,0) PATH 'action/time' 
    ) T2 
    WHERE ( 
      EVENT_ID IS NOT NULL AND ACTION_SUB_ID IS NOT NULL 
    )
    
    
    
    
    

    The plan of the explain command looks like this (sorry, don't know how to get it formatted any 'eye-team'):

    ----------------------------------------------------------------------------------------------------------

    | ID | Operation | Name                        | Lines | Bytes | TempSpc | Cost (% CPU). Time |

    ----------------------------------------------------------------------------------------------------------

    |   0 | SELECT STATEMENT |                             |  1609K |  6316M |       |  6110K (1) | 20:22:11 |

    |*  1 |  HASH JOIN |                             |  1609K |  6316M |   111 M |  6110K (1) | 20:22:11 |

    |   2.   TABLE ACCESS FULL | T_C_RMP_MNTRNG_XML_FULL_IL4 |   582K |   104 M |       |  5241 (1) | 00:01:03 |

    |*  3 |   TABLE ACCESS FULL | T_OR_MON_ACTION |    32 M |   117G |       |   105K (2) | 00:21:08 |

    ----------------------------------------------------------------------------------------------------------

    Information of predicates (identified by the operation identity card):

    ---------------------------------------------------

    1 - access ("NESTED_TABLE_ID"= "T_C_RMP_MNTRNG_XML_FULL_IL4"." ("SYS_NC0001300014$")

    filter (CAST (SYS_XQ_UPKXML2SQL (SYS_XQEXVAL (SYS_XQEXTRACT ((SYS_XMLGEN ("T_C_RMP_MNTRN XMLCONCAT

    G_XML_FULL_IL4 ". "" $ SYS_NC00017 ", NULL, SYS_XMLCONV ("T_C_RMP_MNTRNG_XML_FULL_IL4". "SYS_NC00012$", 0.32,

    (('EC1EEF23FD023A27E04032A06D930A8D', 3, 3783, 1)), SYS_MAKEXML ('EC1EEF23FD023A27E04032A06D930A8D', 3780,

    'T_C_RMP_MNTRNG_XML_FULL_IL4 '. "' SYS_NC00008$ ', 'SYS_ALIAS_0 '. ((("' SYS_NC_ROWINFO$ ')),'/ ID ', NULL), 0,.

    0,20971520,0), 50.1, 2) AS VARCHAR (40)) IS NOT NULL)

    3 filter (CAST (TO_NUMBER (TO_CHAR ("SYS_ALIAS_0". "actionSubId")) AS INTEGER) IS NOT NULL) "

    Note

    -----

    -dynamic sample used for this survey (level = 2)

    -Construction detected no optimized XML (activate XMLOptimizationCheck for more information)

    The XML schema looks like this:

    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" xmlns:oraxdb="http://xmlns.oracle.com/xdb" oraxdb:storeVarrayAsTable="true" oraxdb:flags="2105639" oraxdb:schemaURL="http://mydomain.com/cs.xsd" oraxdb:schemaOwner="MYUSER" oraxdb:numProps="23">
      <xs:element name="monitoring" oraxdb:propNumber="3785" oraxdb:global="true" oraxdb:SQLName="monitoring" oraxdb:SQLType="monitoring755_T" oraxdb:SQLSchema="MYUSER" oraxdb:memType="258" oraxdb:defaultTable="monitoring757_TAB" oraxdb:defaultTableSchema="MYUSER">
        <xs:complexType oraxdb:SQLType="monitoring755_T" oraxdb:SQLSchema="MYUSER">
          <xs:sequence>
            <xs:element maxOccurs="unbounded" ref="action" oraxdb:propNumber="3780" oraxdb:global="false" oraxdb:SQLName="action" oraxdb:SQLType="action752_T" oraxdb:SQLSchema="MYUSER" oraxdb:memType="258" oraxdb:MemInline="false" oraxdb:SQLInline="true" oraxdb:JavaInline="false" oraxdb:SQLCollType="action756_COLL" oraxdb:SQLCollSchema="MYUSER"/>
            <xs:element ref="reservationType" oraxdb:propNumber="3781" oraxdb:global="false" oraxdb:SQLName="reservationType" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:MemInline="false" oraxdb:SQLInline="true" oraxdb:JavaInline="false"/>
            <xs:element ref="softwareVersion" oraxdb:propNumber="3782" oraxdb:global="false" oraxdb:SQLName="softwareVersion" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:MemInline="false" oraxdb:SQLInline="true" oraxdb:JavaInline="false"/>
            <xs:element ref="eventId" oraxdb:propNumber="3783" oraxdb:global="false" oraxdb:SQLName="eventId" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:MemInline="false" oraxdb:SQLInline="true" oraxdb:JavaInline="false"/>
            <xs:element ref="vin" oraxdb:propNumber="3784" oraxdb:global="false" oraxdb:SQLName="vin" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:MemInline="false" oraxdb:SQLInline="true" oraxdb:JavaInline="false"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <xs:element name="action" oraxdb:propNumber="3790" oraxdb:global="true" oraxdb:SQLName="action" oraxdb:SQLType="action752_T" oraxdb:SQLSchema="MYUSER" oraxdb:memType="258" oraxdb:defaultTable="action754_TAB" oraxdb:defaultTableSchema="MYUSER">
        <xs:complexType oraxdb:SQLType="action752_T" oraxdb:SQLSchema="MYUSER">
          <xs:sequence>
            <xs:element ref="type" oraxdb:propNumber="3786" oraxdb:global="false" oraxdb:SQLName="type" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:MemInline="false" oraxdb:SQLInline="true" oraxdb:JavaInline="false"/>
            <xs:element maxOccurs="unbounded" ref="param" oraxdb:propNumber="3787" oraxdb:global="false" oraxdb:SQLName="param" oraxdb:SQLType="param749_T" oraxdb:SQLSchema="MYUSER" oraxdb:memType="258" oraxdb:MemInline="false" oraxdb:SQLInline="true" oraxdb:JavaInline="false" oraxdb:SQLCollType="param753_COLL" oraxdb:SQLCollSchema="MYUSER"/>
            <xs:element ref="actionSubId" oraxdb:propNumber="3788" oraxdb:global="false" oraxdb:SQLName="actionSubId" oraxdb:SQLType="NUMBER" oraxdb:memType="2" oraxdb:MemInline="false" oraxdb:SQLInline="true" oraxdb:JavaInline="false"/>
            <xs:element ref="time" oraxdb:propNumber="3789" oraxdb:global="false" oraxdb:SQLName="time" oraxdb:SQLType="NUMBER" oraxdb:memType="2" oraxdb:MemInline="false" oraxdb:SQLInline="true" oraxdb:JavaInline="false"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <xs:element name="type" type="xs:string" oraxdb:propNumber="3791" oraxdb:global="true" oraxdb:SQLName="type" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:defaultTable="type751_TAB" oraxdb:defaultTableSchema="MYUSER"/>
      <xs:element name="param" oraxdb:propNumber="3794" oraxdb:global="true" oraxdb:SQLName="param" oraxdb:SQLType="param749_T" oraxdb:SQLSchema="MYUSER" oraxdb:memType="258" oraxdb:defaultTable="param750_TAB" oraxdb:defaultTableSchema="MYUSER">
        <xs:complexType oraxdb:SQLType="param749_T" oraxdb:SQLSchema="MYUSER">
          <xs:sequence>
            <xs:element minOccurs="0" ref="value" oraxdb:propNumber="3792" oraxdb:global="false" oraxdb:SQLName="value" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:MemInline="false" oraxdb:SQLInline="true" oraxdb:JavaInline="false"/>
            <xs:element ref="key" oraxdb:propNumber="3793" oraxdb:global="false" oraxdb:SQLName="key" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:MemInline="false" oraxdb:SQLInline="true" oraxdb:JavaInline="false"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <xs:element name="value" type="xs:string" oraxdb:propNumber="3795" oraxdb:global="true" oraxdb:SQLName="value" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:defaultTable="value748_TAB" oraxdb:defaultTableSchema="MYUSER"/>
      <xs:element name="key" type="xs:string" oraxdb:propNumber="3796" oraxdb:global="true" oraxdb:SQLName="key" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:defaultTable="key747_TAB" oraxdb:defaultTableSchema="MYUSER"/>
      <xs:element name="actionSubId" type="xs:integer" oraxdb:propNumber="3797" oraxdb:global="true" oraxdb:SQLName="actionSubId" oraxdb:SQLType="NUMBER" oraxdb:memType="2" oraxdb:defaultTable="actionSubId746_TAB" oraxdb:defaultTableSchema="MYUSER"/>
      <xs:element name="time" type="xs:integer" oraxdb:propNumber="3798" oraxdb:global="true" oraxdb:SQLName="time" oraxdb:SQLType="NUMBER" oraxdb:memType="2" oraxdb:defaultTable="time745_TAB" oraxdb:defaultTableSchema="MYUSER"/>
      <xs:element name="reservationType" type="xs:string" oraxdb:propNumber="3799" oraxdb:global="true" oraxdb:SQLName="reservationType" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:defaultTable="reservationType744_TAB" oraxdb:defaultTableSchema="MYUSER"/>
      <xs:element name="softwareVersion" type="xs:string" oraxdb:propNumber="3800" oraxdb:global="true" oraxdb:SQLName="softwareVersion" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:defaultTable="softwareVersion743_TAB" oraxdb:defaultTableSchema="MYUSER"/>
      <xs:element name="eventId" type="xs:string" oraxdb:propNumber="3801" oraxdb:global="true" oraxdb:SQLName="eventId" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:defaultTable="eventId742_TAB" oraxdb:defaultTableSchema="MYUSER"/>
      <xs:element name="vin" type="xs:string" oraxdb:propNumber="3802" oraxdb:global="true" oraxdb:SQLName="vin" oraxdb:SQLType="VARCHAR2" oraxdb:memType="1" oraxdb:defaultTable="vin741_TAB" oraxdb:defaultTableSchema="MYUSER"/>
    </xs:schema>
    
    
    
    
    

    How can I create an index on these tables of the ordered collection to improve performance?

    I found the example at http://docs.Oracle.com/CD/E11882_01/AppDev.112/e23094/xdb_rewrite.htm#ADXDB5859 but am not able to apply to this particular case...

    Thank you in advance...

    If the schema is not annotated and XS: Integer and XS: String are mapped to types of data NUMBER and VARCHAR2 (4000), so you must use in your query to avoid typecasting unnecessary operations.

    You must also use XMLTABLEs chained when accessing a parent/child instead of a FLWOR expression relationship, otherwise the CBO cannot rewrite the XQuery query correctly (maybe it's fixed in the latest version).

    If you make these changes, the plan should show the cleaner predicates:

    SQL > SELECT EVENT_ID, MESSAGE_ID, ACTION_TYPE, ACTION_SUB_ID, ACTION_TIMESTAMP

    2 FROM test_table

    3 XMLTABLE ('/ monitoring ')

    4 COLUMNS XML_CONTENT OF PASSAGE

    5 WAY of VARCHAR2 (4000) EVENT_ID "ID."

    6 actions for XMLTYPE PATH 'action '.

    (7) T1,

    8 XMLTABLE ('/ action')

    Shares of PASSAGE 9 COLUMNS

    NUMBER of ACTION_SUB_ID 10 PATH "actionSubId."

    11 PATH of VARCHAR2 (4000) ACTION_TYPE "type."

    12 WAY of NUMBER ACTION_TIMESTAMP 'time '.

    (13) T2

    14 WHERE EVENT_ID IS NOT NULL

    15 AND ACTION_SUB_ID IS NOT NULL

    16;

    Execution plan

    ----------------------------------------------------------

    Hash value of plan: 1763884463

    ------------------------------------------------------------------------------------------------

    | ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time |

    ------------------------------------------------------------------------------------------------

    |   0 | SELECT STATEMENT |                 |   109.   220K |     6 (17). 00:00:01 |

    |   1.  THE MERGE JOIN.                 |   109.   220K |     6 (17). 00:00:01 |

    |*  2 |   TABLE ACCESS BY INDEX ROWID | TEST_TABLE |    11.   352.     2 (0) | 00:00:01 |

    |   3.    INDEX SCAN FULL | SYS_C007567 |    11.       |     1 (0) | 00:00:01 |

    |*  4 |   JOIN TYPE.                 |   109.   216K |     4 (25) | 00:00:01 |

    |*  5 |    TABLE ACCESS FULL | T_OR_MON_ACTION |   106 S 216K |     3 (0) | 00:00:01 |

    ------------------------------------------------------------------------------------------------

    Information of predicates (identified by the operation identity card):

    ---------------------------------------------------

    2 - filter("TEST_TABLE".") (' SYS_NC00012$ ' IS NOT NULL)

    4 - access("SYS_ALIAS_0".") NESTED_TABLE_ID "=" TABLE_TEST. " ("' SYS_NC0000800009$ ')

    filter ("SYS_ALIAS_0". "NESTED_TABLE_ID"="TABLE_TEST" "." " ("SYS_NC0000800009$")

    5 - filter("SYS_ALIAS_0"." actionSubId» IS NOT NULL)

    Note

    -----

    -dynamic sample used for this survey (level = 2)

    Now, if it is still necessary, everything boils down to choosing a technique for index NULL values:

    -composite index with a column not zero or constant

    -FBI

    -bitmap image

    Choose the one that best fits your data, the selectivity and activity on the tables.

  • ORA-03113 when inserting a CLOB value cast as an XMLType of a SELECT query in a table

    I have a table that contains a CLOB column with pseudo-XML in it. I want to keep these data in an XMLType column so that I can take advantage of some of the built-in XML features of Oracle to analyze more easily.

    The source table is defined as:

    CREATE TABLE "TSS_SRM_CBEBRE_LOGS_V"

    ( ) NUMBER of 'INCIDENT_ID',

    ACTIVATE THE "EVENT_TYPE" VARCHAR2 (100 BYTE) NOT NULL,

    VARCHAR2 (100 BYTE) "EVENT_KEY."

    ACTIVATE THE 'CREATION_DATE' STAMP (6) NOT NULL,

    ACTIVATE THE 'CREATED_BY' VARCHAR2 (100 BYTE) NOT NULL,

    'LOG_MSG' CLOB) ;


    The target table (to test this problem) is defined as:

    CREATE TABLE 'TESTME '.

    ("LOG_MSG" "XMLTYPE"

    )

    My query is:

    Insert / * + APPEND * / into testme ("LOG_MSG")

    Select XMLTYPE.createXML ("LOG_MSG") as "TSS_SRM_CBEBRE_LOGS_V" b LOG_MSG;

    In SQL * Developer, my error is: error report:

    SQL error: No more data to read from socket

    In SQL * MORE and Toad, my error is:

    ORA-03113: end of file on communication channel

    Process ID: 13903

    Session ID: serial number 414: 32739

    Thank you!

    I made an ALTER SESSION SET EVENTs = 10046 trace name forever, context level 12'; and ran the query. At the bottom of the trace file, I found the two following exceptions of ORA-07445:

    * 13:43:32.760 2013-08-15

    Exception [type: SIGSEGV, SI_KERNEL (general_protection)] [ADDR:0 x 0] [PC:0 x 2652500, LpxMemFree () + 200] [flags: 0x0, count: 1]

    Incident 493726 created the dump file: /u01/app/oracle/diag/rdbms/gtcdwd1/gtcdwd1/incident/incdir_493726/gtcdwd1_ora_8577_i493726.trc

    [ORA-07445: exception encountered: core dump [LpxMemFree () + 200] [SIGSEGV] [ADDR:0 x 0] [PC:0 x 2652500] [SI_KERNEL (general_protection)]]

    Incident 493727 created the dump file: /u01/app/oracle/diag/rdbms/gtcdwd1/gtcdwd1/incident/incdir_493727/gtcdwd1_ora_8577_i493727.trc

    [ORA-07445: exception encountered: core dump [dbgtrReserveSpace () + 77] [SIGSEGV] [ADDR:0 x 0] [PC:0x938E91F] [SI_KERNEL (general_protection)]]

    ORA-07445: exception encountered: core dump [LpxMemFree () + 200] [SIGSEGV] [ADDR:0 x 0] [PC:0 x 2652500] [SI_KERNEL (genres

    ksdbgcra: base of writing to the directory file ' / u01/app/oracle/diag/rdbms/gtcdwd1/gtcdwd1/cdump ".

    If I replace the XMLTYPE molded with the xmlparse function, I get the error ORA-19010 you mentioned. Read more in the Oracle documentation, I see that it says that I can not insert XML fragments into an XMLType column. I can use sys_XMLGen to create a well-formed document.

    http://docs.Oracle.com/CD/B28359_01/AppDev.111/b28369/xdb13gen.htm#i1026349

    We'll see!

  • Syntax of XQuery OK in 11R2, but works only not in 10R2

    I am new to XQuery and I am struggling a little with her, I wrote an insert in our environment 11R2 and when he was deployed in customer 10R2 environment throws an error:
    select x.stmt
    from source_table vdx1
    ,    xmltable(xmlnamespaces(default 'urn:iso:std:iso:20022:tech:xsd:camt.053.001.02')
                  ,'for $i in /Document/BkToCstmrStmt/Stmt where $i/Bal/Amt/@Ccy = $ccy return $i'
                  passing vdx1.content
                  , cast(l_ccy_code as varchar2(3)) as "ccy"
                  columns Stmt xmltype path '/*'
                 ) x
    where vdx1.id = l_vdx_id
    
    ORA-00932: inconsistent datatypes: expected - got CHAR
    The problem lies in the line with "cast", I have basically that data when the value of /Bal/Amt/@Ccy is equal to a certain value that is stored in the variable l_ccy_code. This value varies, so I can just hardcode it.

    Is there a way to write this select statement that would be correct for 10R2 environments both 11R2? Is there a better way to write the XQuery for my case, that's what I came up with, but because of my lack of experience with XQuery, it would not be the best solution?

    10.2, the PASSAGE clause allows only XMLType datatype.

    If you pass simple scalar values as in your example, you can use this workaround:

    select x.stmt
    from source_table vdx1
    ,    xmltable(xmlnamespaces(default 'urn:iso:std:iso:20022:tech:xsd:camt.053.001.02')
                  ,'for $i in /Document/BkToCstmrStmt/Stmt where $i/Bal/Amt/@Ccy = $ccy return $i'
                  passing vdx1.content
                  , sys_xmlgen(l_ccy_code) as "ccy"
                  columns Stmt xmltype path '.'
                 ) x
    where vdx1.id = l_vdx_id
    
  • Query to generate nested XML flow

    Hello
    I use Oracle 11 g R2 SOE...

    I have two main tables

    COMMERCIALS_PROPERTIES (PK, com_id, com_size, project number, com_type number number number)
    COM_PHOTOS (PK ID number, number com_id FK, content mimetype varchar2, blob)

    Please, note that the following has nothing to do with my problem:
    CONTENT and mimetype columns. In addition, the tables of research: PROJECTS, COM_TYPE

    I exposed a report as a RESTful web service in XML format:

    I use this query to generate the XML 1 feed, but I need to change the query to generate flow XML 2 .

    How is this possible?
     Select
          
    "COM"."COM_ID" as "COM_ID",
    "COM"."COM_SIZE" as "SIZE",
    "PROJECTS"."PROJECT_NAME_EN" as "PROJECT",
    "COM_TYPES"."COM_TYPE" as "COM_TYPE",
    
    'http://fam-erp.com/apex/erp/fateh/'||IMG.ID as "ImgURL"
    
     FROM 
    COM_PHOTOS IMG inner join COMMERCIALS_PROPERTIES "COM"
    on   IMG.COM_ID = COM.COM_ID
    inner join "PROJECTS" "PROJECTS" 
    on "PROJECTS"."PROJECT_ID"="COM"."PROJECT_ID"
    inner join "COM_TYPE_LOOKUP" "COM_TYPES" 
    on "COM_TYPES"."TYPE_ID"="COM"."COM_TYPE"
         
     WHERE
      COM.COM_ID < 80 order by 1
    H1. XML 1
    H2. Please look only < COM_ID > and < ImgURL >
    <ROWSET>
    <ROW>
    <COM_ID>77</COM_ID>
    <SIZE>842</SIZE>
    <PROJECT>Bayswater Tower</PROJECT>
    <COM_TYPE>Office</COM_TYPE>
    <ImgURL>http://fam-erp.com/apex/erp/fateh/1410</ImgURL>
    </ROW>
    
    <ROW>
    <COM_ID>77</COM_ID>
    <SIZE>842</SIZE>
    <PROJECT>Bayswater Tower</PROJECT>
    <COM_TYPE>Office</COM_TYPE>
    <ImgURL>http://fam-erp.com/apex/erp/fateh/1412</ImgURL>
    </ROW>
    
    <ROW>
    <COM_ID>78</COM_ID>
    <SIZE>756</SIZE>
    <PROJECT>Bayswater Tower</PROJECT>
    <COM_TYPE>Office</COM_TYPE>
    <ImgURL>http://fam-erp.com/apex/erp/fateh/1425</ImgURL>
    </ROW>
    
    <ROW>
    <COM_ID>78</COM_ID>
    <SIZE>756</SIZE>
    <PROJECT>Bayswater Tower</PROJECT>
    <COM_TYPE>Office</COM_TYPE>
    <ImgURL>http://fam-erp.com/apex/erp/fateh/1429</ImgURL>
    </ROW>
    
    </ROWSET>
    ---------------------------
    H1. XML 2
    H2. Please look only < COM_ID > and < Images > and < ImgURL >
    <ROWSET>
    <ROW>
    <COM_ID>77</COM_ID>
    <SIZE>842</SIZE>
    <PROJECT>Bayswater Tower</PROJECT>
    <COM_TYPE>Office</COM_TYPE>
    <Images>
          <ImgURL>http://fam-erp.com/apex/erp/fateh/1410</ImgURL>
          <ImgURL>http://fam-erp.com/apex/erp/fateh/1412</ImgURL>
    </Images>
    </ROW>
    
    <ROW>
    <COM_ID>78</COM_ID>
    <SIZE>756</SIZE>
    <PROJECT>Bayswater Tower</PROJECT>
    <COM_TYPE>Office</COM_TYPE>
    <Images>
            <ImgURL>http://fam-erp.com/apex/erp/fateh/1425</ImgURL>
            <ImgURL>http://fam-erp.com/apex/erp/fateh/1429</ImgURL>
    </Images>
    </ROW>
    </ROWSET>
    
     

    Fateh,

    I really doubt if the nested XML can be generated from one part of the report. The and tags to link to a generic XML generator that takes a select as input. Just like SYS_XMLGEN or DBMS_XMLGEN.

    You will need find an alternative mechanism for the nested XML.

    Below are the 2 links to help you started on its SQL. For deployment, you can use ApexListener ResourceTemplates, if you use ApexListener.

    If you are on 4.2 Apex and ApexListener 2.0EA, then you have more options that you can set the modules of RESTful services in SQLWorkshop.

    http://asktom.Oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:4980337843276
    http://asktom.Oracle.com/pls/asktom/f?p=100:11:P11_QUESTION_ID:11650482108651

    Kind regards

  • Transform XML - Strip/add/rename nodes all at once what I can?

    First, I'll start with you request is not to shoot me down in flames; I did not design this system, I just have to work with the resultant, erm, bunch of steam...! I can only apologize for inflicting it on the rest of the world!

    I'm on 10.2.0.4 (although we will migrate to 11.2.0.2 or (hopefully) 11.2.0.3 in the coming months or more, so I'm open to answers additional 11g), and we currently store our XMLTYPE columns (Marco, look away now!) as a CLOB and will continue to do so when we went to 11 g (unfortunately, GoldenGate replica binary XML * {:-())

    We are currently receiving XML from a number of different systems in and - of course - everyone goes into it differently. In particular, we have moved the following XML:
     -- ignore this, had to put in an extra one to get the formatting to work! {noformat}*scratches head*{noformat}
    & lt; Node1 & gt;
    & lt; node2 & gt;
    & lt; Node3 & gt;
    & lt; Node4 & gt; Value1 & lt; / node4 & gt;
    & lt; Node5 & gt;
    & lt; Node6 & gt; value2 & lt; / node6 & gt;
    & lt; Node7 & gt; value3 & lt; / node7 & gt;
    & lt; / node5 & gt;
    & lt; / node3 & gt;
    & lt; node8 & gt;
    & lt; node9 att1 = "Name1" & gt;
    & lt; node10 & gt; Value4 & lt; / node10 & gt;
    & lt; node11 & gt; Value5 & lt; / node11 & gt;
    .....
    & lt; / node9 & gt;
    & lt; / node8 & gt;
    & lt; / node2 & gt;
    & lt; / node1 & gt;
    and it gets messed around via a number of replaces and concatenation (after converting the XMLTYPE back to a CLOB and then back into an XMLTYPE...) into the following format:
    & lt; made_up_node1 att_new1 = "Name2" & gt;
    & lt; node9_renamed att1 = "Name1" & gt;
    & lt; node10 & gt; Value4 & lt; / node10 & gt;
    & lt; node11 & gt; Value5 & lt; / node11 & gt;
    .....
    & lt; / node9_renamed & gt;
    & lt; made_up_node2 att_new2 = "Name3" & gt;
    & lt; made_up_node3 & gt;
    & lt; Node4 & gt; Value1 & lt; / node4 & gt;
    & lt; Node6 & gt; value2 & lt; / node6 & gt;
    & lt; Node7 & gt; value3 & lt; / node7 & gt;
    & lt; / made_up_node3 & gt;
    & lt; / made_up_node2 & gt;
    & lt; / made_up_node1 & gt;
    The above takes the entirety of the node9, puts it under a new root node and renames it, plus takes some of the values from nodes before node9 and puts them in a new set of nodes at the end.
    
    I've worked out how to rename the "node9" to "node9_renamed":
    with my_xml as (select xmltype ("< node1 > ' |"))
    "< node2 > |
    "< node3 > |
    "value1 < node4 > < / node4 > ' |"
    "< Noeud5 >" |
    ' < node6 > value2 < / node6 > ' |
    "value3 < node7 > < / node7 > ' |"
    ' < / node5 > ' |
    ' < / node3 > ' |
    "< node8 >" |
    '< node9 = "Name1" att1 >' |
    "value4 < node10 > < / node10 > ' |"
    ' Value5 < node11 > < / node11 > ' |
    ' < / node9 > ' |
    ' < / node8 > ' |
    ' < / node2 > ' |
    (/ node1 > ') xml_col
    the double).
    trans_xml as (select XMLTransform (mx.xml_col,
    XmlType ("< xsl: stylesheet version ="1.0"xmlns: xsl =" http://www.w3.org/1999/XSL/Transform"> ' |)
    "< xsl: output method ="xml"/ >" | "
    "< xsl: template match =" node () | " @*" >'||
    "< xsl: Copy > |
    "< xsl: apply-templates select =" node () | " @* » / >'||
    ' < / xsl: Copy > ' |
    ' < / xsl: template > ' |
    ' < xsl: template match = "node9" > ' |
    ' < xsl: name = "node9_renamed" > ' |
    "< xsl: apply-templates select =" node () | " @* » / >'||
    ' < / xsl: > ' |
    ' < / xsl: template > ' |
    ((/ xsl: stylesheet > ')) new_xml
    of my_xml mx)
    Select *.
    of trans_xml;
    but I got that from googling and searching the forums. I know nothing about xslt and, after looking at the documentation on http://www.w3.org/TR/xslt, I've just about managed to work out what most of the xslt does above, but can't for the life of me work out if my requirement is even possible, let alone how to go about doing it!
    
    So, my question is: is it possible to rewrite the XML as per "my" requirements using XMLTRANSFORM and if it is, how do I go about it? Or, is it going to be better to stick to the current method of extracting stuff from the XML, concatenating it as appropriate and then converting back to an XMLTYPE?
    
    Edited by: Boneist on 31-Jul-2012 15:59 - corrected formatting                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        

    OK, so I tried to change the XMLQuery method to make the name change of the nodes 4, 6 and 7, but the values are coming as empty? I tried with "/ (* |)» *)») * "and" / * "at the end, nothing helps.

    In the XPath language, * means any child element of the current node (and @* means any attribute).
    In your example of XML, there is no element under noeud4, node6, and node7, so the new element is empty.

    To copy the original value of the item, you must use the text() accessor or the Text() function:

    select xmlquery(
    '
    {
      element node9_renamed { $d/node1/node2/node8/node9/(*|@*) }
    , 
        
        {
          element node4_renamed { $d/node1/node2/node3/node4/text() }
        , element node6_renamed { $d/node1/node2/node3/node5/node6/text() }
        , element node7_renamed { $d/node1/node2/node3/node5/node7/text() }
        }
        
      
    }
    '
    passing t.doc as "d"
          , sys_xmlgen('name2') as "att_new1"
          , sys_xmlgen('name3') as "att_new2"
    returning content
    )
    from tmp_xml t;
    
  • date attribute xmltype.toObject)

    Hi guys,.

    I use a database 11g and I'm trying to convert xml into an object
    but I have problems to date fields oracle
    for example: < CREATED_DATE > 2012-08-18T 18: 15:31.8673829 + 01:00 < / CREATED_DATE > cannot be inserted as of the CREATED_DATE,.

    I tried the oracle default format yyyy-mm - ddThh24:mi:ss, but it does not work, the only things that work is NLS_DATE_FORMAT (LUN-JJ-AA).
    Is it possible to do this?
    CREATE OR REPLACE TYPE GROUP_STATEMENT_REC AS OBJECT(
    GROUP_STATEMENT_ID           NUMBER(10),  
    GROUP_ID                     VARCHAR2(5), 
    CUSTOMER_ID                  NUMBER(10),  
    CREATED_DATE                 DATE,        
    REPORT_GENERATED_DATE        DATE,        
    EVENT_ID                     NUMBER(10),  
    YEAR                         VARCHAR2(4), 
    MONTH                        VARCHAR2(2), 
    CURRENCY_CODE                VARCHAR2(3), 
    OPENING_BALANCE              NUMBER(17,2),
    CLOSING_BALANCE              NUMBER(17,2),
    CUSTOMER_COLLECTION_HOLD_IND VARCHAR2(1), 
    CUSTOMER_DISPUTE_IND         VARCHAR2(1) 
    ) FINAL INSTANTIABLE;
    
    
    
    CREATE OR REPLACE TYPE GROUP_STATEMENT_COL IS TABLE OF GROUP_STATEMENT_REC;
    
    
    create or replace type gsbox is object (container GROUP_STATEMENT_COL);
    
    
     
     
     declare
    
        lc_gs   GROUP_STATEMENT_COL := GROUP_STATEMENT_COL(GROUP_STATEMENT_REC(1,'40666',1000,sysdate,sysdate,11,'2004','10','EUR',123.23,32.23,'Y','N'),
                                                             GROUP_STATEMENT_REC(2,'40600',1001,sysdate-1,sysdate,12,'2004','10','EUR',123.23,32.23,'Y','N'));
        xmlgs         xmltype;
        l_box         gsbox;
        newgs         GROUP_STATEMENT_COL;
        
      begin
    
    --dbms_output.put_line(lc_gs.count);
      -- select sys_xmlgen(gsbox(lc_gs)) into xmlgs from dual;
      xmlgs := new XMLType('<?xml version="1.0" encoding="utf-8"?>
    <ROW xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <CONTAINER>
        <GROUP_STATEMENT_REC>
          <GROUP_STATEMENT_ID>0</GROUP_STATEMENT_ID>
          <GROUP_ID>30888</GROUP_ID>
          <CUSTOMER_ID>39</CUSTOMER_ID>
          <CREATED_DATE>2012-08-18T18:15:31.8673829+01:00</CREATED_DATE>
          <REPORT_GENERATED_DATE xsi:nil="true" />
          <EVENT_ID>0</EVENT_ID>
          <YEAR>2012</YEAR>
          <MONTH>7</MONTH>
          <CURRENCY_CODE>GBP</CURRENCY_CODE>
          <OPENING_BALANCE>4405.08</OPENING_BALANCE>
          <CLOSING_BALANCE>4405.08</CLOSING_BALANCE>
          <CUSTOMER_COLLECTION_HOLD_IND>N</CUSTOMER_COLLECTION_HOLD_IND>
          <CUSTOMER_DISPUTE_IND>N</CUSTOMER_DISPUTE_IND>
          
        </GROUP_STATEMENT_REC>
      </CONTAINER>
    </ROW>'); 
       --dbms_output.put_line(xmlgs.getStringVal());
       xmlgs.toObject(l_box);
       newgs := l_box.container;
    
       for i in 1..newgs.count loop
        dbms_output.put_line(newgs(i).GROUP_STATEMENT_ID || ' : ' || newgs(i).GROUP_ID||newgs(i).REPORT_GENERATED_DATE||newgs(i).YEAR||'<<<');
       end loop;
     
      end;
      

    Hello

    I have problems to date fields oracle
    for example:2012-08 - 18 T 18: 15:31.8673829 + 01:00 cannot be inserted as of the CREATED_DATE,.

    This format matches the TIMESTAMP WITH TIME ZONE data type in Oracle.

    Change the CREATED_DATE attribute to:

    CREATED_DATE                 TIMESTAMP WITH TIME ZONE, 
    

    Then you should be able to do this:

    SQL> alter session set nls_timestamp_tz_format = 'YYYY-MM-DD"T"HH24:MI:SS.FFTZH:TZM';
    
    Session altered
    
    SQL> declare
      2
      3    xmlgs         xmltype;
      4    l_box         gsbox;
      5    newgs         GROUP_STATEMENT_COL;
      6
      7  begin
      8
      9    xmlgs := new XMLType('
     10  
     11    
     12      
     13        0
     14        30888
     15        39
     16        2012-08-18T18:15:31.8673829+01:00
     17        
     18        0
     19        2012
     20        7
     21        GBP
     22        4405.08
     23        4405.08
     24        N
     25        N
     26
     27      
     28    
     29  ');
     30
     31    xmlgs.toObject(l_box);
     32    newgs := l_box.container;
     33
     34    for i in 1..newgs.count loop
     35      dbms_output.put_line(newgs(i).CREATED_DATE);
     36    end loop;
     37
     38  end;
     39  /
    
    2012-08-18T18:15:31.867383+01:00
    
    PL/SQL procedure successfully completed
     
    
  • Aggregation of knots in a string

    My google-fu and forum-fu are clearly miss me today, because I can't find examples of aggregation of XML nodes in a string of an existing piece of XML - there must be a way! I found a few examples of XMLAGG and XMLELEMENT but they were based on non - XML columns, and I can't make heads-or-tails of the documentation.
    So, here is my XML example:
    with sd as (select xmltype('<Fruits>
                                  <Fruit>
                                    <FruitType>Apple</FruitType>
                                    <FruitSubtype>Granny Smith</FruitSubtype>
                                  </Fruit>
                                  <Fruit>
                                    <FruitType>Pear</FruitType>
                                    <FruitSubtype>Anjou</FruitSubtype>
                                  </Fruit>
                                  <Fruit>
                                    <FruitType>Pear</FruitType>
                                    <FruitSubtype>Comice</FruitSubtype>
                                  </Fruit>
                                  <Fruit>
                                    <FruitType>Plum</FruitType>
                                    <FruitSubtype>Victoria</FruitSubtype>
                                  </Fruit>
                                  <Fruit>
                                    <FruitType>Apple</FruitType>
                                    <FruitSubtype>Bramley</FruitSubtype>
                                  </Fruit>
                                </Fruits>') fruit_xml from dual)
    select *
    from   sd;
    and here is the result I want (I'm only interested FruitType = 'Apple'):
    Granny SmithBramley
    NB. There is no delimiter used.

    For what it's worth, this is the code that I am trying to replace:
    FOR rec IN (SELECT EXTRACT(VALUE(d), '/Fruit/FruitType/text()').GETSTRINGVAL() fruit_type,
                       EXTRACT(VALUE(d), '/Fruit/FruitSubtype/text()').GETSTRINGVAL() fruit_subtype
                 FROM TABLE(XMLSEQUENCE(EXTRACT(p_fruits, '//Fruits'))) d) LOOP
        IF rec.fruit_type = 'Apple' THEN
            l_fruit_subtypes := l_fruit_subtypes || rec.fruit_subtype;
        END IF;
    END LOOP;
    We are currently using 10.2.0.4, but will move to 11.2.0.2 more later this year, so I'm after something that will be 11 GR 2 compliant so that I don't have to rewrite later.

    I could replicate the above cursor for loop using XMLTABLE to extract values, but I would like to do if possible in a SQL statement.

    Any ideas, please?

    We are currently using 10.2.0.4, but will move to 11.2.0.2 more later this year, so I'm after something that will be 11 GR 2 compliant so that I don't have to rewrite later.

    Here's a way (11g only):

    select xmlcast(
             xmlquery(
               '/Fruits/Fruit[FruitType=$mytype]/FruitSubtype/text()'
                passing sd.fruit_xml
                      , 'Apple' as "mytype"
                returning content
             ) as varchar2(4000)
           )
    from sd
    ;
    

    10.2 equivalent closest would be:

    select xmlquery(
             '/Fruits/Fruit[FruitType=$mytype]/FruitSubtype/text()'
             passing sd.fruit_xml
                   , sys_xmlgen('Apple') as "mytype"
             returning content
           ).getstringval()
    from sd
    ;
    

    Or, using XMLTable:

    select x.result
    from sd,
         xmltable(
           'string-join(/Fruits/Fruit[FruitType=$mytype]/FruitSubtype,"")'
           passing sd.fruit_xml
                 , 'Apple' as "mytype"
           columns result varchar2(4000) path '.'
         ) x
    ;
    
  • How to retrieve the value of base on the value on other nodes

    Hi, I have a XML below
    <? XML version = "1.0" encoding = "iso-8859-1"? > <? XML-stylesheet type = "text/xsl" href="C:\temp\horizontal.xsl"? " >
    < Type report = "REPORT" >
    < prop Type = 'Result' Flags = "0 x 0" > "
    < prop Name = 'STEP' Type = "Obj" Flags = "0 x 0" > "
    < prop Name = 'Sequence' >
    < prop Name = 'RList' >
    < ArrayElementPrototype Type = "TEResult" Flags = "0 x 0" > "
    < / ArrayElementPrototype >
    < value ID "[0]" = >
    < prop Type = 'Result' Flags = "0 x 0" > "
    < prop Name = "Status" Type = "String" Flags = "0x400000" > "
    < value > < / value >
    < / prop >
    < prop Name = "ReportText" Type = "String" Flags = "0x400000" > "
    < value > < / value >
    < / prop >
    < prop Name = "Common" Type = "Obj" TypeName = "CommonResults" Flags = "0 x 0" > "
    < / prop >

    < / prop >
    < / value >
    < value ID "[60]" = > = > ID is not set
    < prop Type = 'Result' Flags = "0 x 0" > "
    < prop Name = "Error" Type = "Obj" TypeName = "Error" Flags = "0x400000" > "
    < prop Name = "Code" Type = "Number" Flags = "0x400000" > "
    < value > 0 < / value >
    < / prop >
    < prop Name = "Msg" Type = "String" Flags = "0x400000" > "
    < value > < / value >
    < / prop >
    < prop Name = "occurred" Type = "Boolean" Flags = "0x400000" > "
    < value > false < / value >
    < / prop >
    < / prop >
    < prop Name = "Status" Type = "String" Flags = "0x400000" > "
    < value > spent < / value >
    < / prop >
    < prop Name = "Numeric" Type = "Number" NumFmt = "%i" Flags = "0 x 2400" > "
    < Value > * 88 * < / value > = > value I want back
    < / prop >
    < prop Name = "ReportText" Type = "String" Flags = "0x400000" > "
    < value > < / value >
    < / prop >
    < prop Name = "Common" Type = "Obj" TypeName = "CommonResults" Flags = "0 x 0" > "
    < / prop >
    < prop Name = "Units" Type = "String" Flags = "0x2000" > "
    < Value >TESTDATA< / value > = > basic data
    < / prop >

    < / prop >
    < / value >

    < / prop >
    < / prop >
    < / prop >
    < / prop >
    < / report >

    I want to retrieve the value 88 the TESTDATA found in this node, can someone show me how to recover?

    Thank you

    Vincent

    Published by: pj * April 29, 2011 01:14

    Yes, it is possible, but the query will be slightly less effective.

    SELECT XMLQuery(
            'for $i in $d/descendant::Value/Prop
             where $i/Prop[@Name="Units"]/Value = $PropValue
             return $i/Prop[@Name="Numeric"]/Value/text()'
             passing t.object_value as "d"
                   , sys_xmlgen('TESTDATA') as "PropValue"
             returning content
           ).getNumberVal()
           as result
    FROM test_xml t
    ;
    
  • Using XMLTYPE and cursor I get ORA-01000

    When I run this example I get:

    ORA-01000: cursors open maximum exceeded
    01000 00000 - "maximum open cursors exceeded".
    * Cause:
    * Action:

    < {code >}
    drop table model.
    create the dummy (pidm number (8) of the table)
    , Name varchar2 (20)
    , name varchar2 (20)
    , phone varchar2 (12)
    , Dept varchar2 (6)
    , In_Case_Emerg varchar2 (20)
    , Zip varchar2 (5)
    , Field_A varchar2 (5)
    , Field_B varchar2 (5)
    , Field_C varchar2 (5)
    , Field_D varchar2 (5)
    , Field_E varchar2 (5)
    , Field_F varchar2 (5)
    , Field_G varchar2 (5)
    , Field_H varchar2 (5)
    , Field_I varchar2 (5)
    , Field_J varchar2 (5)
    , Field_K varchar2 (5)
    , Field_L varchar2 (5)
    , Field_M varchar2 (5)
    , Field_N varchar2 (5)
    , Field_o varchar2 (5)
    , Field_P varchar2 (5)
    , Field_Q varchar2 (5)
    , Field_R varchar2 (5)
    , Field_S varchar2 (5)
    , Field_T varchar2 (5)
    , Field_U varchar2 (5)
    , Field_V varchar2 (5)
    , Field_W varchar2 (5)
    , Field_X varchar2 (5)
    , Field_Y varchar2 (5)
    , Field_Z varchar2 (5)
    );
    Insert into dummy(pidm,lastname,firstname,phone,dept)
    values(649,'Doe','Jane','1234','FINAC');
    Insert into dummy (pidm, lastname, firstname, dept)
    values(649,'Doe','Jane','CUST');
    Insert into dummy(pidm,lastname,firstname,phone,dept)
    values(649,'Doe','Jane','3456','REPAIR');
    Insert into dummy (pidm, lastname, firstname, dept)
    values(649,'Doe','Jane','PARTS');

    ----------------------------

    Select
    Z.Akey, Z.dept, Z.column_name, Y.dvalue
    Y.Deptorg, Y.drecord
    CEN
    Select
    Upper (Trim (C.Dept)) deptorg
    Annals of t.column_value.getrootelement)
    (, t.column_value.extract('//text () ') value
    model c
    table
    (xmlsequence
    (xmltype
    (cursor
    (
    Select d.
    model d
    where d.dept = c.dept
    AND d.pidm = 649
    )
    ).extract('rowset/row/*')
    )
    ) t
    where c.pidm = 649
    Order at the top (c.dept), Annals
    ) (Right outer join Y)
    Select J.column_name, K.dept, J.akey
    de)
    Select B.column_name, '1' akey
    Of user_tab_columns B
    where upper (B.table_name) = upper ('dummy')
    () Join the inner J)
    Select distinct '1' akey, UPPER (dept) dept
    where dummy pidm = 649
    ) K
    ON J.Akey = K.Akey
    ORDER BY J.column_name, K.dept
    ) Z
    ON Y.DRECORD = Z.COLUMN_NAME
    AND Y.Deptorg = Z.Dept
    WHERE Z.akey = '1'
    order of Z.dept, Z.column_name

    < code >
    However when I do

    update set = 123 pidm dummy where DEPT = 'PARTIES ';

    The query above works.

    Is it possible to make the above query without having a cursor limit?

    If this is the wrong forum, please tell me the right forum?

    Suggestions?

    TIA
    Steve42

    Hi Steve,.

    The following query should work:

    WITH t1 AS (
      SELECT *
      FROM XMLTable(
       'for $i in ora:view("DUMMY")/ROW[PIDM=xs:integer($pidm)]
          , $j in $i/child::*
        return element r
        {
          $i/DEPT
        , element COLUMN_NAME {name($j)}
        , element DVALUE      {$j}
        }'
       passing sys_xmlgen(649) as "pidm"
       columns dept        varchar2(6)  path 'DEPT'
             , column_name varchar2(30) path 'COLUMN_NAME'
             , dvalue      varchar2(30) path 'DVALUE'
      )
    ),
    t2 AS (
      SELECT column_name, column_id
      FROM user_tab_columns
      WHERE table_name = 'DUMMY'
    )
    SELECT t1.dept, column_name, t1.dvalue
    FROM t1
         PARTITION BY (dept)
         RIGHT OUTER JOIN t2 USING (column_name)
    ORDER BY t1.dept, t2.column_id
    ;
    

    The subquery "t1" is pretty much the same as the one you used with XMLSequence.

    XMLTable has been introduced in version 10.2 and now replaces XMLSequence:
    http://download.Oracle.com/docs/CD/B19306_01/AppDev.102/b14259/xdb_xquery.htm#sthref1705

    Another useful feature here is the "partitioned outer join", that allow outer join independently each group of the Department to the list in the column.

  • Unable to connect to Oracle with sqlplus /nolog as sysdba

    Oracle has turned on the box [Red Hat Enterprise Linux ES release 4 (Nahant Update 6)] taking up all the CPU.

    When I try and connect with sqlplus /nolog as sysdba nothing happens, no output.

    All ideas, apart reboot the box please?

    We tried to kill all Oracle processes too & restart the listener, but what gives the same...

    Log the following...

    version 10.2.0.1.0 =

    Oh, its happened before, the last time, we couldn't get by is rebooted then the box - it was fine then.


    $. oraenv
    ORACLE_SID = [oralt]?
    dbhome
    ORACLE_HOME = /u01/oracle/oracle/product/10.2.0/db_1
    ORACLE_SID = oralt

    RH4 - ora - t3:oracle:oralt/opt/oracle$ sqlplus/nolog

    (Nothing)

    VI /u01/oracle/oracle/product/10.2.0/db_1/admin/oralt/bdump/alert_oralt.log

    Mon. Nov 22 02:01:57 2010
    Notification of memory: Cache object library loaded in SGA
    5118K heap size exceed the threshold of notification (2048K)
    Details in the path of the /u01/oracle/oracle/product/10.2.0/db_1/admin/oralt/udump/oralt_ora_12801.trc file
    Name of the KGL object: SELECT / * + rule * / SYS_XMLGEN (VALUE(KU$), XMLFORMAT.createFormat2 ('TABLE_T', ' 7')), KU$. SYS OBJ_NUM. KU KU _FHTABLE_VIEW $ WHERE NOT (BITAND (KU$.)) (PROPERTY, 8192) = 8192) AND NOT BITAND (KU$.) SCHEMA_OBJ. FLAGS, 128)! = 0 AND KU$. $ SCHEMA_OBJ.NAME =: NAME1 AND KU. SCHEMA_OBJ. OWNER_NAME =: SCHEMA2
    Mon Nov 22 11:13:21 2010
    Thread 1 Advanced for you connect to sequence 3280
    Currently Journal # 3 seq # 3280 mem # 0: /u02/oradata/oralt/redo03_1.rdo
    Currently Journal # 3 seq # 3280 mem # 1: /u03/oradata/oralt/redo03_2.log

    (end)


    RH4 - ora - t3:oracle:oralt/opt/oracle$ top
    Top - 10:27:16 up to 199 days, 19:32, 2 users, load average: 24.82, 24.67, 24,19
    Activities: 146 total, 30 running, 116 sleeping, 0 stopped, 0 zombie
    CPU: 38.0% us, sy 62.0% 0.0% ni, id 0.0% 0.0% wa, 0.0% Hi, 0.0% if
    MEM: 3115248 k total, 2736140 k used, 379108 k free, k buffers 247956
    Swap: 6289436 k total, 80168 k used, 6209268 k free, 2229880 k cached

    THE NEST PR NOR % CPU TIME + % MEM VIRT RES SHR S COMMAND USE
    2173 25 0 17 263:51.52 2.5 oracle 607 m 74 m 70 m R oracle
    2211 25 0 17 260:43.53 620 oracle 0.7 m 21 m 10 m R oracle
    2154 25 0 17 262:21.71 605 oracle 0.5 m 14 m 13 m R oracle
    2159 25 0 17 262:38.20 604 oracle 0.8 m 24 m 23 m R oracle
    2161 25 0 17 263:05.82 3.1 oracle 607 m 93 m 90 m R oracle
    2163 25 0 17 261:55.21 620 oracle 0.7 m 19 m 18 m R oracle
    2165 25 0 17 261:13.85 606 oracle 0.8 m 24 m 22 m R oracle
    2169 25 0 17 261:47.42 605 oracle 0.8 m 22 m 21 m R oracle
    2171 25 0 17 263:20.01 1.8 oracle 606 m 55 m 52 m R oracle
    2175 25 0 17 263:03.81 604 oracle 0.7 m 22 m 21 m R oracle
    2177 25 0 17 262:15.91 605 oracle 0.4 m 10 m 9500 R oracle
    2209 25 0 17 261:55.91 620 oracle 0.7 m 22 m 10 m R oracle
    2745 25 0 17 257:08.69 604 oracle 0.5 m 15 m 14 m R oracle
    6885 25 0 17 89:05.80 0.1 19652 4564 3228 R exp oracle
    10344 25 0 17 1:26.30 0.2 91856 6584 5720 R oracle oracle
    17568 25 0 17 263:29.11 605 oracle 0.7 m 21 m 19 m R oracle
    22383 25 0 17 0.1 19576 4600 3280 R sqlplus oracle 111:38.92
    22:56.01 27963 25 0 17 0.2 91856 6584 5720 R oracle oracle
    8185 25 0 16 169:09.85 0.2 29816 6004 3300 R rman oracle
    13633 25 0 16 261:50.72 605 oracle 0.5 m 14 m 13 m R oracle
    12518 25 0 16 260:35.53 605 oracle 0.5 m 14 m 13 m R oracle
    2156 oracle 15 0 25 262:28.54 604 0.4 m 11 m 9.9 m R oracle
    2167 oracle 15 0 25 261:06.86 3.2 606 m 98 m 95 m R oracle
    2669 oracle 15 0 25 261:46.97 604 0.6 m 18 m 16 m R oracle
    0:00.09 root 15816 17 0 1 0.0 5680 1332 1052 R hpetfe
    0:00.12 root 15663 16 0 1 0.1 7968 2348 1852 R sshd
    0:00.19 root 15767 16 0 1 0.0 2156 1056 780 high R
    0:00.15 high 15768 16 0 1 0.0 1948 1048 784 R oracle
    1 root 16 0 0:58.86 0 0.0 2468 548 468 init S
    2 root RT 0 0 3:44.17 0 0.0 0 0 S migration/0
    3 34 19 0:12.75 root 0 0.0 0 0 S 0 ksoftirqd/0
    4 root RT 0 0 4:24.86 0 0.0 0 0 S migration/1
    5 34 19 0:11.23 roots 0 0.0 0 0 0 S ksoftirqd/1
    6 root RT 0 0 4:28.40 0 0.0 0 0 S migration/2
    7 34 19 0:12.55 roots 0 0.0 0 0 0 S ksoftirqd/2
    8 root RT 0 0 3:59.44 0 0.0 0 0 S migration/3
    9 root of 34 19 0:13.29 0 0.0 0 0 0 S ksoftirqd/3
    10 root-5 10 0 0:00.84 0 0.0 0 0 events/0 S
    11 root-5 10 0 0:00.43 0 0.0 0 0 events/1 S
    12 root-5 10 0 0:01.82 0 0.0 0 0 events/2 S
    13 root-5 10 0 0:00.80 0 0.0 0 0 events/3 S
    14 root 6-10 3:08.62 0 0.0 0 0 0 S khelper
    15 root-5 10 0 0:00.00 0 0.0 0 S 0 kblockd/0


    backkup #killed jobs...
    RH4 - ora - t3:oracle:oralt/opt/oracle$ kill 6885
    RH4 - ora - t3:oracle:oralt/opt/oracle$ kill 8185
    RH4 - ora - t3:oracle:oralt/opt/oracle$ kill 22383


    RH4 - ora - t3:oracle:oralt/opt/oracle$ lsnrctl

    LSNRCTL for Linux: Version 10.2.0.1.0 - Production on November 23, 2010 10:37:39

    Copyright (c) 1991, 2005, Oracle. All rights reserved.

    Welcome to LSNRCTL, enter 'help' for more information.

    LSNRCTL > status
    Connection to (DESCRIPTION = (ADDRESS = (PROTOCOL = IPC) (KEY = EXTPROC1)))
    STATUS of the LISTENER
    ------------------------
    Alias LISTENER
    Version TNSLSNR for Linux: Version 10.2.0.1.0 - Production
    Start date August 6, 2010 14:57:55
    Uptime 108 days 20 h 39 min 46 s
    Draw level off
    Security ON: OS Local Authentication
    SNMP ON
    Parameter Listener of the /u01/oracle/oracle/product/10.2.0/db_1/network/admin/listener.ora file
    The listener log file /U01/Oracle/Oracle/product/10.2.0/Db_1/network/log/listener.log
    Summary of endpoints listening...
    (DESCRIPTION = (ADDRESS = (PROTOCOL = ipc) (KEY = EXTPROC1)))
    (DESCRIPTION = (ADDRESS = (PROTOCOL = tcp)(HOST=10.1.209.208) (PORT = 1521)))
    Summary of services...
    Service 'PLSExtProc' has 1 instance (s).
    Instance of 'PLSExtProc', status UNKNOWN, has 1 operation for this service...
    Service 'oralt' has 1 instance (s).
    'Oralt' instance, State LOAN, has 1 operation for this service...
    Service 'oraltXDB' has 1 instance (s).
    'Oralt' instance, State LOAN, has 1 operation for this service...
    Service 'oralt_XPT' has 1 instance (s).
    'Oralt' instance, State LOAN, has 1 operation for this service...
    The command completed successfully
    LSNRCTL > stop
    Connection to (DESCRIPTION = (ADDRESS = (PROTOCOL = IPC) (KEY = EXTPROC1)))
    beginning

    (Nothing)

    RH4 - ora - t3:oracle:oralt/opt/oracle$ running time
    10:38:35 up to 199 days, 19:43, 2 users, load average: 23.13, 23.30, 23.62


    (a lot of play with earphone - but it does not start and it won't let me connect to sqlplus /nolog)

    Killed all the processors of Oracle, still unable to connect to sqlplus


    Tasks: running, 97 98 1 total sleeping, 0 stopped, 0 zombie
    CPU: 0.7% us, sy 0.2% 0.0% or 99.1% id, 0.0% wa, 0.0% Hi, 0.0% if
    MEM: 3115248 k total, 2679604 k used, 435644 k free, 248572 k buffers
    Swap: 6289436 k total, 80168 k used, 6209268 k free, 2271904 k cached

    THE NEST PR NOR % CPU TIME + % MEM VIRT RES SHR S COMMAND USE
    1 root 16 0 0:58.87 0 0.0 2468 548 468 init S
    2 root RT 0 0 3:44.19 0 0.0 0 0 S migration/0
    3 34 19 0:12.75 root 0 0.0 0 0 S 0 ksoftirqd/0
    4 root RT 0 0 4:24.88 0 0.0 0 0 S migration/1
    5 34 19 0:11.23 roots 0 0.0 0 0 0 S ksoftirqd/1
    6 root RT 0 0 4:28.42 0 0.0 0 0 S migration/2
    7 34 19 0:12.55 roots 0 0.0 0 0 0 S ksoftirqd/2
    8 root RT 0 0 3:59.45 0 0.0 0 0 S migration/3
    9 root of 34 19 0:13.29 0 0.0 0 0 0 S ksoftirqd/3
    10 root-5 10 0 0:00.84 0 0.0 0 0 events/0 S
    11 root-5 10 0 0:00.43 0 0.0 0 0 events/1 S
    12 root-5 10 0 0:01.82 0 0.0 0 0 events/2 S
    13 root-5 10 0 0:00.80 0 0.0 0 0 events/3 S
    14 root 6-10 3:08.63 0 0.0 0 0 0 S khelper
    15 root-5 10 0 0:00.00 0 0.0 0 S 0 kblockd/0
    root-5 16 10 0 0:00.00 0 0.0 0 0 S kblockd/1
    17 root-5 10 0 0:00.01 0 0.0 0 0 S kblockd/2
    18 root-5 10 0 0:00.00 0 0.0 0 0 S kblockd/3
    19 root 15 0 0 0:00.00 0 0.0 0 0 S khubd
    the square root of 69 15 0 0 3:20.26 0 0.0 0 0 S pdflush
    root 70 16 0 0 2:25.34 0 0.0 0 0 S pdflush
    root of 71 16 0 0 53:43.69 0 0.0 0 0 S kswapd0
    root of 72-6 10 0 0:00.00 0 0.0 0 0 aio/0 S
    root 73 6 - 10 0:00.00 0 0.0 0 0 0 S aio/1
    root 74 6 - 10 0:00.00 0 0.0 0 0 0 aio/2 S
    75 root 6-10 0:00.00 0 0.0 0 0 0 aio/3 S
    219 root 25 0 0 0:00.00 0 0.0 0 0 S kseriod
    462 root 25 0 0 0:00.00 0 0.0 0 0 S scsi_eh_0
    463 root 15 0 0 0:00.00 0 0.0 0 0 S ahc_dv_0
    465 root 19 0 0 0:00.00 0 0.0 0 0 S scsi_eh_1
    466 root 15 0 0 0:00.00 0 0.0 0 0 S ahc_dv_1
    502 root 15 0 0 5:02.83 0 0.0 0 0 S kjournald
    1064 root 6-10 0:00.00 0 0.0 0 0 0 S kauditd
    1683 root 6-10 0:00.05 0 0,0 3336 448 368 S udevd
    1795 root 25 0 0 0:00.00 0 0.0 0 0 S phpd_event
    root of 1957 15 0 0 0:00.01 0 0.0 0 0 S kjournald
    root of 1958 15 0 0 0:00.01 0 0.0 0 0 S kjournald
    root of 1959 15 0 0 0:01.44 0 0.0 0 0 S kjournald
    1960 root 15 0 0 0:12.13 0 0.0 0 0 S kjournald
    1961 root 15 0 0 0:04.08 0 0.0 0 0 S kjournald
    1962 root 15 0 0 0:03.89 0 0.0 0 0 S kjournald
    the square root of 15 1963 0 0 0:04.93 0 0.0 0 0 S kjournald
    root 1964 15 0 0 39:23.43 0 0.0 0 0 S kjournald

    Edited by: sunpat November 23, 2010 11:52

    http://www.lmgtfy.com/?q=Oracle+Linux+uptime+bug

  • Reg: DBMS_XMLDOM. Error of DOMDocument

    Hi all
    I tried to create the xml document in the C drive.
    I created this directory as:
    create or replace directory ctemp1 as "C:\". » ;
    GRANT ALL ON ctemp1 to the public DIRECTORY;
    Grant read, write on directory ctemp1 to the public;

    The code is:
    DECLARE
    doc DBMS_XMLDOM. DOMDocument;
    XData XMLTYPE.
    cursor XMLCUR is SYS_XMLGEN (XMLAGG (XMLELEMENT ("EMPNO", ename))) select of EMP;
    Cursor xmlCurdate is
    Select (SYS_XMLGen)
    XMLELEMENT (NAME "UTIMEID",
    XMLATTRIBUTES (to_char ((sysdate-1), 'YYYYMMDD') as a "uid",)
    TO_CHAR ((sysdate-1),' dd/mm/yyyy (') | rtrim (to_char ((sysdate-1), 'Day')) |) "like"uiddesc")),"
    sys.xmlgenformatType.createFormat ("UPDATED - XML')) twice;
    BEGIN
    OPEN xmlcur.
    SEEK xmlcur INTO xdata;
    CLOSE Xmlcur;
    doc: = DBMS_XMLDOM. NewDOMDocument (xdata);
    DBMS_XMLDOM. WRITETOFILE (doc, 'ctemp1': '-' |') Alert.XML');
    OPEN xmlcurdate.
    SEEK xmlcurdate INTO xdata;
    CLOSE Xmlcurdate;
    doc: = DBMS_XMLDOM. NewDOMDocument (xdata);
    DBMS_XMLDOM. WRITETOFILE (doc, 'ctemp1': '-' |') Updated.XML');
    END;

    Get the error message like:

    Error from the 8 in the command line:
    DECLARE
    doc DBMS_XMLDOM. DOMDocument;
    XData XMLTYPE.
    cursor XMLCUR is SYS_XMLGEN (XMLAGG (XMLELEMENT ("EMPNO", ename))) select of EMP;
    Cursor xmlCurdate is
    Select (SYS_XMLGen)
    XMLELEMENT (NAME "UTIMEID",
    XMLATTRIBUTES (to_char ((sysdate-1), 'YYYYMMDD') as a "uid",)
    TO_CHAR ((sysdate-1),' dd/mm/yyyy (') | rtrim (to_char ((sysdate-1), 'Day')) |) "like"uiddesc")),"
    sys.xmlgenformatType.createFormat ("UPDATED - XML')) twice;
    BEGIN
    OPEN xmlcur.
    SEEK xmlcur INTO xdata;
    CLOSE Xmlcur;
    doc: = DBMS_XMLDOM. NewDOMDocument (xdata);
    DBMS_XMLDOM. WRITETOFILE (doc, 'ctemp1': '-' |') Alert.XML');
    OPEN xmlcurdate.
    SEEK xmlcurdate INTO xdata;
    CLOSE Xmlcurdate;
    doc: = DBMS_XMLDOM. NewDOMDocument (xdata);
    DBMS_XMLDOM. WRITETOFILE (doc, 'ctemp1': '-' |') Updated.XML');
    END;
    Error report:
    ORA-29280: invalid directory path
    ORA-06512: at "SYS." UTL_FILE", line 33
    ORA-06512: at "SYS." UTL_FILE", line 436
    ORA-06512: at "XDB". DBMS_XSLPROCESSOR", line 217
    ORA-29280: invalid directory path
    ORA-29280: invalid directory path
    ORA-06512: at "XDB". DBMS_XMLDOM", line 4416
    ORA-06512: at line 16 level
    29280 00000 - "invalid directory path.
    * Cause: A corresponding directory object does not exist.
    * Action: Correct the parameter object directory, or create a correspondent
    object directory with the command CREATE a DIRECTORY.
    Please help on this.
    Thanks in advence.

    When you create objects in the database (tables, views, directories etc.) then by default they are stored in the dictionary of data on top of case (unless you surround the name with double quotes, which is a poor practice).

    So in your DBMS_XMLDOM. Call WRITETOFILE you must specify the name of the directory in uppercase...

    DBMS_XMLDOM.WRITETOFILE(doc, 'CTEMP1'||...
    

    ... simple as that. ;)

  • Combine the 2 tables in XML

    Table T1:
    C1  C2  C3  
    --- --- --- 
    1   2   3   
    10  20  30  
    100 200 300 
    Table T2:
    COL1 COL2 
    ---- ---- 
    A    B    
    AA   BB   
    Desired output:
    <ROWSET>
         <T1>
              <C1>1</C1>
              <C2>2</C2>
              <C3>3</C3>
         </T1>
         <T1>
              <C1>10</C1>
              <C2>20</C2>
              <C3>30</C3>
         </T1>
         <T1>
              <C1>100</C1>
              <C2>200</C2>
              <C3>300</C3>
         </T1>
         <T2>
              <COL1>A</COL1>
              <COL2>B</COL2>
         </T2>
         <T2>
              <COL1>AA</COL1>
              <COL2>BB</COL2>
         </T2>
    </ROWSET>
    Help, please. Thank you.

    with t1 as
    (
    Select c1 '1', ' 2 ', 3' c2 c3 double
    Union
    Select ' 10 ', 20', 30' of the double
    Union
    Select ' 100 ', ' 200', 300' of the double
    )
    t2 as
    (
    Select col1, col2 'B' double ' A'
    Union
    Select "AA", "BB" of double
    )
    Select...

    Here's one way:

    SQL>  with t1 as
    (
     select '1' c1, '2' c2, '3' c3 from dual union all
     select '10' , '20' , '30' from dual union all
     select '100' , '200' , '300' from dual
    )
    , t2 as
    (
     select 'A' col1, 'B' col2 from dual union all
     select 'AA' , 'BB' from dual
    )
    select xmlserialize(content sys_xmlagg(x) indent) x from (
     select xmlelement("T1", sys_xmlgen(c1), sys_xmlgen(c2), sys_xmlgen(c3)) x from t1
      union all
     select xmlelement("T2", sys_xmlgen(col1), sys_xmlgen(col2)) from t2
    )
    
    X
    ------------------------------
    
    
      
        1
        2
        3
      
      
        10
        20
        30
      
      
        100
        200
        300
      
      
        A
        B
      
      
        AA
        BB
      
                         
    
    1 row selected.
    

    Note: xmlserialize is just for formatting the output and not necessary in general.

Maybe you are looking for