SQL/XML and Inline views

I learn just XQuery and SQL/XML and believe that SQL/XML that will work best for my current need.

Is it possible to do to the line and subqueries in SQL/XML, everything as we often use in SQL? The data that I will need at least two views inline who stand in the FROM of the SQL statement.

In principle, this should be possible, but you need to develop a little more, so far it's a pretty general question. The preferred method of 10.2(.0.3.0) and would be XQuery, if only it is much more powerful than "SQL/XML", while dealing with XML data.

Tags: Database

Similar Questions

  • Need help with query SQL Inline views + Group

    Hello gurus,

    I would really appreciate your time and effort on this application. I have the following data set.

    Reference_No---Check_Number---Check_Date---description---Invoice_Number---Invoice_Type---Paid_Amount---Vendor_Number
    1234567 11223 - 05/07/2008 -paid for cleaning- 44345563-I-* 20.00 *---19
    1234567 11223 - 05/07/2008 - 44345563 -a--10,00---19 ofbad quality adjustment
    7654321 11223 - 05/07/2008 - setting the last billing cycle - 23543556 - A - 50.00 - 19
    4653456 11223 - 05/07/2008 - paid for cleaning - 35654765 - I - 30, 00-19

    Please ignore '-' added for clarity

    I'm writing a paid_amount based on Reference_No, Check_Number, Payment_Date, Invoice_Number, aggregate query Invoice_Type, Vendor_Number and display description with Invoice_type 'I' when there are multiple records with the same Reference_No, Check_Number, Payment_Date, Invoice_Type, Invoice_Number, Vendor_Number. When there are no more records I want to display the respective Description.

    The query should return the following data set

    Reference_No---Check_Number---Check_Date---description---Invoice_Number---Invoice_Type---Paid_Amount---Vendor_Number
    1234567 11223 - 05/07/2008 -paid for cleaning- 44345563-I-* 10.00 *---19
    7654321 11223 - 05/07/2008 - setting the last billing cycle - 23543556 - A - 50.00 - 19
    4653456 11223 - 05/07/2008 - paid for cleaning - 35654765 - I - 30, 00-19
    Here's my query. I'm a little lost.

    Select b., A.sequence_id, A.check_date, A.check_number, A.invoice_number, A.amount, A.vendor_number
    de)
    Select sequence_id, check_number, check_date, invoice_number, sum (paid_amount) sum, vendor_number
    of the INVOICE
    Sequence_id group check_date, check_number, invoice_number, vendor_number
    ) A, B OF INVOICE
    where A.sequence_id = B.sequence_id


    Thank you
    Nick

    It seems that this is a duplicate thread - correct me if I am wrong in this case->

    Need help with query SQL Inline views + Group

    Kind regards.

    LOULOU.

  • XML and SQL output

    Hi all

    Please find test data and results as XML and SQL output.

    Version : Oracle Database 11 g Enterprise Edition Release 11.1.0.7.0 - 64 bit Production

    create table emp_xml (empno number, emp_name varchar2 (100), by e-mail to varchar2 (100));

    insert into emp_xml values (100, 'DAVID',' [email protected]');

    insert into emp_xml values (101, 'ROBERT',' [email protected]');

    insert into emp_xml values (102, 'DANIEL',' [email protected]');

    CREATE table emp_dept_xml (empno number, dept_list varchar2 (4000));

    insert into emp_dept_xml values (' 100,'10, 20, 30, ");

    insert into emp_dept_xml values (' 101,'40, 20, 10, 30, 50, ");

    insert into emp_dept_xml values (102, ' 10'),

    Expected in SQL output

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

    EMPNO EMP_NAME EMAIL DEPTNO

    DAVID 100 [email protected] 10

    DAVID 100 [email protected] 20

    DAVID 100 [email protected] 30

    ROBERT 101 [email protected] 10

    ROBERT 101 [email protected] 20

    ROBERT 101 [email protected] 30

    ROBERT 101 [email protected] 40

    ROBERT 101 [email protected] 50

    DANIEL 102 [email protected] 10

    Results in XML

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

    < USERS_DETAILS >

    < USER >

    < EMPNO > 100 < / EMPNO >

    DAVID < NAME > < / NAME >

    < EMAIL > [email protected] < / EMAIL >

    < ASSIGNED_DEPT >

    < DEPT > 10 < / DEPT >

    < DEPT > 20 < / DEPT >

    < DEPT > 30 < / DEPT >

    < / ASSIGNED_DEPT >

    < / USER >

    < USER >

    101/EMPNO < EMPNO > >

    ROBERT < NAME > < / NAME >

    < EMAIL > [email protected] < / EMAIL >

    < ASSIGNED_DEPT >

    < DEPT > 10 < / DEPT >

    < DEPT > 20 < / DEPT >

    < DEPT > 30 < / DEPT >

    < DEPT > 40 < / DEPT >

    < DEPT > 50 < / DEPT >

    < / ASSIGNED_DEPT >

    < / USER >

    < USER >

    < > 102 EMPNO < / EMPNO >

    DANIEL < NAME > < / NAME >

    < EMAIL > [email protected] < / EMAIL >

    < ASSIGNED_DEPT >

    < DEPT > 10 < / DEPT >

    < / ASSIGNED_DEPT >

    < / USER >

    < / USERS_DETAILS >

    Thank you

    Rambeau

    SQL>   select e.empno
      2         , e.emp_name
      3         , e.email
      4         , regexp_substr(d.dept_list, '[^,]+', 1, level) deptno
      5      from emp_xml e
      6      join emp_dept_xml d
      7        on e.empno = d.empno
      8   connect
      9        by level <= length(d.dept_list) - length(replace(dept_list, ','))
     10       and prior e.empno = e.empno
     11       and prior dbms_random.value() is not null;
    
         EMPNO EMP_NAME             EMAIL                DEPTNO
    ---------- -------------------- -------------------- --------------------
           100 DAVID                [email protected]      10
           100 DAVID                [email protected]      20
           100 DAVID                [email protected]      30
           101 ROBERT               [email protected]     40
           101 ROBERT               [email protected]     20
           101 ROBERT               [email protected]     10
           101 ROBERT               [email protected]     30
           101 ROBERT               [email protected]     50
           102 DANIEL               [email protected]     10
    
    9 rows selected.
    
    SQL> select xmlelement
      2         (
      3              "USERS_DETAILS"
      4            , xmlagg(xmlelement
      5              (
      6                  "USER"
      7                , xmlelement("EMPNO", empno)
      8                , xmlelement("NAME", emp_name)
      9                , xmlelement("ASSIGNED_DEPT", xmlagg(xmlelement("DEPT", deptno)))
     10              ))
     11         ).extract('*') xml_output
     12    from (
     13            select e.empno
     14                 , e.emp_name
     15                 , e.email
     16                 , regexp_substr(d.dept_list, '[^,]+', 1, level) deptno
     17              from emp_xml e
     18              join emp_dept_xml d
     19                on e.empno = d.empno
     20           connect
     21                by level <= length(d.dept_list) - length(replace(dept_list, ','))
     22               and prior e.empno = e.empno
     23               and prior dbms_random.value() is not null
     24         )
     25   group
     26      by empno
     27       , emp_name;
    
    XML_OUTPUT
    --------------------------------------------------------------------------------
    
      
        100
        DAVID
        
          10
          20
          30
        
      
      
        101
        ROBERT
        
          40
          50
          30
          20
          10
        
      
      
        102
        DANIEL
        
          10
        
      
    
    
    SQL>
    
  • Is there a tool to view / get the SQL XML format?

    Hello
    Work on Oracle 11g R2 SOE.
    It is my first try with XML function, suppose I have a query similar to the one mentioned here, how to get a well formatted by this query XML file?
    I run on SQL Plus and tried 'Spool' in the xml file, but information was not in XML format.
    select xmlelement(
             "DEPARTMENTS",
             xmlagg(
               xmlelement(
                 "DEPARTMENT",
                 xmlforest(
                   d.deptno,
                   d.dname,
                   (
                     select xmlagg(
                              xmlelement(
                                "EMPLOYEE",
                                 xmlforest(
                                   e.empno,
                                   xmlcdata(e.ename) ename,
                                   e.hiredate
                                 )
                               )
                            )
                     from   emp e
                     where  e.deptno = d.deptno and
                            e.empno in (7369, 7499, 7934)
                   ) employees
                 )
               )
             )
           ) x
    from   dept d;
    Kind regards
    Fateh

    Fateh says:
    Thank you
    Yes, I meant by good - as XML, the same format you obtained as a result of your query.

    The point is that the expression "well formatted" in terms XML, means an XML document that has the opening and closing etc and responds to the XML standard. It does not mean one that is displayed in a way enough with all the beautiful indented of the hierarchy. This is called a "pretty print" XML document

    As Odie, for technical purposes you need only a well formatted XML document, because if you insist on using a pretty print XML, then you introduce a lot of white space in the document, which will make the XML content conisiderably of large files for example more big or bigger storage required. To treat XML programmatically there not enough print XML at all.

    So, why do you need your print by little data?

    If you have data stored in an XML file, you can simply open it in a web browser and it will present this pretty print for you... If it's just a case of you want to be able to browse the data for testing etc.

  • Replication of data between SQL Server and using Oracle11g materialized view.

    I have Sqlserver 2005 as my source and oracle11g as my target. I need fill out the target daily with change of the source data.
    to do this, we created a dblink between SQL Server and oracle and reproduced this table as a point of view, materialized in Oracle.
    problem that we get here is fast refresh option is not available.each day it will pick up all of the data source.
    is it possible to use Fast refresh in this scenario?

    Thanks in advance.

    Kind regards
    Balaram.

    You can try MS SQL replication.
    Configure transactional Standard of MS SQL and Oracle Publication subscriber http://msdn.microsoft.com/en-us/library/ms151738%28v=sql.90%29.aspx

  • PHP, xml and Flash

    Hello

    Someone can help me. I try to query an sql database and echo the image in xml format so I can display the image in flash.

    I already know how to query and echo the url of the image of the database.

    This is the code:

    The database is queried at this stage already.

    echo "<? XML version=\"1.01\"? " "> \n";

    echo "< content > \n";

    While ($Nile = mysql_fetch_assoc (Run))

    {

    echo "< point >." $nile ['content']. "" < / item > \n ";

    }

    echo "< / content > \n";

    Flash I creat table to insert a URL and an xml object echoes images. It looks like this.

    This is after you have created the table of object and xml next url the loop for to insert the XML.

    thexml.onLoad = function)

    {

    var photos: Array = thisfirstChild.childNodes;

    for (i = 0; i < photos.length; i ++)

    {

    This pushes the XML in a table of URLs

    URLs.push (photos [i]. Attributes.URL);

    }

    This is supposed to load individual data into the flash movie object.

    movieobject.loadMovie(urls[0]);

    movieobject.loadMovie(urls[1]);

    }

    x.Load (Content.php);

    The echo in the first code xml produces a url link that contains a link to an image in the database. The flash is supposed to display the image on a flash clip call movieobject animation. I have some difficulty in getting the image displayed in flash. If anyone can change or provide the new code, it would be really useful.

    More PHP XML , you can view

  • Problem SQL Developer and GeoRaptor

    Hi all

    I installed sql developer version 1.5.0.52 and in a schema, I have space, but like geo raptor data in not installed with sql developer if I'm unable to see the spatial data.

    In order to see the spatial data so I installed Geo Raptor as below:

    Click on the 'Help' menu item and "check update".

    2. "Find updates - welcome" dialog box

    Click on the Next"" button.

    3. dialogue "Check for Updates - step 1 of 3: Source".
    Add the new Update Center. Click on the 'Add' button and insert values:

    Name: GeoRaptor
    Location: http://georaptor.sourceforge.net/install.xml

    And developer sql update successfully, but after the installation of Geo Raptor so I am unable to find the Geo Raptor tool in SQL Developer.

    Could someone help me please why Geo Raptor tool is not dispaying in SQL Developer.

    Thanks in advance
    Vipin

    Vipin,

    I am one of the developers for GeoRaptor.

    I notice that you use version 1.5.0.52 SQL Developer.

    The current version of SQL Developer work with version 2.1 and more.

    Download the latest version of SQL Developer (I run version 2.1.1.64) and reinstall GeoRaptor.

    If the installation is correct, you should see a menu entry GeoRaptor to the pillar of the view menu. In addition, you
    should see GeoRaptor commands on the right mouse click menus on columns of tables/sdo_geometry.

    Let me know if you still have problems.

    concerning
    Simon

  • What is microsoft xps document writer and xps Viewer and how to use it?

    What is microsoft xps document writer and xps Viewer and how to use it?

    Original title: xps document writer and Viewer

    Hi arunin,.

    An XPS document is a file that is saved in the XML Paper Specification, or .xps, file format. You can create documents XPS (.xps files) by using any program that you can print from Windows; However, you can only view XPS documents by using an XPS Viewer, such as the one included in this version of Windows.

    See: http://windows.microsoft.com/en-in/windows/what-is-xps-viewer#what-is-xps-viewer=windows-7

    http://Windows.Microsoft.com/en-in/Windows-Vista/print-to-the-Microsoft-XPS-document-writer

  • Re-write the code DOM node with SQL - XML funtions

    Hi friends,

    Could you please help to re - write the code using the following SQl - XML functions

    DECLARE

    l_domdoc dbms_xmldom. DOMDocument;

    l_xmltype XMLTYPE.

    l_root_node dbms_xmldom. DOMNode;

    l_departments_node dbms_xmldom. DOMNode;

    l_dept_element dbms_xmldom. DOMElement.

    l_dept_node dbms_xmldom. DOMNode;

    l_name_node dbms_xmldom. DOMNode;

    l_name_textnode dbms_xmldom. DOMNode;

    l_location_node dbms_xmldom. DOMNode;

    l_location_textnode dbms_xmldom. DOMNode;

    l_employees_node dbms_xmldom. DOMNode;

    l_emp_element dbms_xmldom. DOMElement.

    l_emp_node dbms_xmldom. DOMNode;

    l_emp_first_name_node dbms_xmldom. DOMNode;

    l_emp_first_name_textnode dbms_xmldom. DOMNode;

    l_emp_last_name_node dbms_xmldom. DOMNode;

    l_emp_last_name_textnode dbms_xmldom. DOMNode;

    BEGIN

    -Create an empty XML document

    l_domdoc: = dbms_xmldom.newDomDocument;

    -Create a root node

    l_root_node: = dbms_xmldom.makeNode (l_domdoc);

    -Create a new node departments and add it to the root node

    l_departments_node: = dbms_xmldom.appendChild (l_root_node

    , dbms_xmldom.makeNode (dbms_xmldom.createElement (l_domdoc, 'Deptartments'))

    );

    FOR r_dept IN (SELECT dept.department_id

    dept.department_name

    loc.city

    SERVICE dept

    JOIN the loc site

    ON loc.location_id = dept.location_id

    WHERE dept.department_id IN (10.20)

    )

    LOOP

    -For each folder, create a new item Dept with the service as an attribute ID.

    - and add this new Dept element in the node of departments

    l_dept_element: = dbms_xmldom.createElement (l_domdoc, "Dept");

    dbms_xmldom.SetAttribute (l_dept_element, 'Deptno', r_dept. Department_id);

    l_dept_node: = dbms_xmldom.appendChild (l_departments_node

    dbms_xmldom.makeNode (l_dept_element)

    );

    -Each node Dept will get a node names that contains the name of the service as a text

    l_name_node: = dbms_xmldom.appendChild (l_dept_node

    , dbms_xmldom.makeNode (dbms_xmldom.createElement (l_domdoc, 'Name'))

    );

    l_name_textnode: = dbms_xmldom.appendChild (l_name_node

    dbms_xmldom.makeNode (dbms_xmldom.createTextNode (l_domdoc, r_dept.department_name))

    );

    -Each node Dept will also get a node to the location that contains the location (city) in the form of text

    l_location_node: = dbms_xmldom.appendChild (l_dept_node

    , dbms_xmldom.makeNode (dbms_xmldom.createElement (l_domdoc, 'Location'))

    );

    l_location_textnode: = dbms_xmldom.appendChild (l_location_node

    dbms_xmldom.makeNode (dbms_xmldom.createTextNode (l_domdoc, r_dept.city))

    );

    -For each Department, add a node of employees

    l_employees_node: = dbms_xmldom.appendChild (l_dept_node

    , dbms_xmldom.makeNode (dbms_xmldom.createElement (l_domdoc, 'Employees'))

    );

    FOR r_emp IN (SELECT employee_id

    first name

    last_name

    Employees

    WHERE department_id = r_dept.department_id

    )

    LOOP

    -For each folder, create a new item Emp with the employee as an attribute ID.

    - and add this new element of the Emp to the employees node

    l_emp_element: = dbms_xmldom.createElement (l_domdoc, 'Emp');

    dbms_xmldom.SetAttribute (l_emp_element, "empid", r_emp.employee_id);

    l_emp_node: = dbms_xmldom.appendChild (l_employees_node

    dbms_xmldom.makeNode (l_emp_element)

    );

    -Each node emp will get a first name and a last name node that contains the first name and the last name text

    l_emp_first_name_node: = dbms_xmldom.appendChild (l_emp_node

    , dbms_xmldom.makeNode (dbms_xmldom.createElement (l_domdoc, "FirstName"))

    );

    l_emp_first_name_textnode: = dbms_xmldom.appendChild (l_emp_first_name_node

    dbms_xmldom.makeNode (dbms_xmldom.createTextNode (l_domdoc, r_emp.first_name))

    );

    l_emp_last_name_node: = dbms_xmldom.appendChild (l_emp_node

    , dbms_xmldom.makeNode (dbms_xmldom.createElement (l_domdoc, "LastName"))

    );

    l_emp_last_name_textnode: = dbms_xmldom.appendChild (l_emp_last_name_node

    dbms_xmldom.makeNode (dbms_xmldom.createTextNode (l_domdoc, r_emp.last_name))

    );

    END LOOP;

    END LOOP;

    l_xmltype: = dbms_xmldom.getXmlType (l_domdoc);

    dbms_xmldom.freeDocument (l_domdoc);

    dbms_output.put_line (l_xmltype.getClobVal);

    END;

    /


    Thank you and best regards,

    Arun Thomas T

    It's as simple as that:

    SQL> select xmlserialize(document
      2           xmlelement("Departments"
      3           , xmlagg(
      4               xmlelement("Dept"
      5               , xmlattributes(d.department_id as "Deptno")
      6               , xmlforest(
      7                   d.department_name as "Name"
      8                 , l.city as "Location"
      9                 )
     10               , xmlelement("Employees"
     11                 , (
     12                     select xmlagg(
     13                              xmlelement("Emp"
     14                              , xmlattributes(e.employee_id as "empid")
     15                              , xmlforest(
     16                                  e.first_name as "FirstName"
     17                                , e.last_name as "LastName"
     18                                )
     19                              )
     20                            )
     21                     from hr.employees e
     22                     where e.department_id = d.department_id
     23                   )
     24                 )
     25               )
     26             )
     27           )
     28           indent
     29         )
     30  from hr.departments d
     31       join hr.locations l on l.location_id = d.location_id
     32  where d.department_id in (10,20) ;
    
    XMLSERIALIZE(DOCUMENTXMLELEMEN
    --------------------------------------------------------------------------------
    
      
        Administration
        Seattle
        
          
            Jennifer
            Whalen
          
        
      
      
        Marketing
        Toronto
        
          
            Michael
            Hartstein
          
          
            Pat
            Fay
          
        
      
    
    
  • Direct manipulation of XMLTYPE with SQL / (XML)

    I have temporary XMLTYPEs in my PL/SQL code. I want to handle these temporary XMLs with SQL, as the UPDATE and UPDATEXML.

    I'm new to processing XML and what I find in the documentation is first to make a table, put the XML file into it, and then I can handle with SQL like this (pseudo-code):

    CREATE TABLE xml_table OF XMLTYPE;
    INSERT INTO xml_table values (l_xml);
    UPDATE xml_table SET = UPDATEXML(…) WHERE …;
    
    

    But I don't want to do (temporary) tables to organize my XML files. I just want to treat them directly as this (pseudo-code):

    UPDATE l_xml SET = UPDATEXML(…) WHERE ….;

    So my questions are:

    1. can even direct manipulation of XMLTYPE with SQL and
    2. What is the preferred method for XML processing (attribute values) if my functions are of the form "function(xml XMLTYPE) RETURN XMLTYPE"; (e.g. my überhaupt approach is sane?)

    Handling of XML with SQL using DOUBLE is SQL sentence.

    Of course, it is.

    But I understand what you mean.

    When I talked about manipulating XML with SQL I thought about something like this (pseudocode)

    Yes, what you had in mind is exactly that, pseudocode. It does not work like that.

    XQuery Update Facility is supported since 12cR1

    11.2.0.3 actually, but it does not matter in your case.

    Given your version, DOM is probably the best way, or a PL/SQL loop:

    SQL > declare

    2

    3 entry xmltype: = xmltype ('ABCXYZ');

    4

    5. start

    6

    7 r in)

    8 select id, val | '-' || TO_CHAR (ID) as new_val

    xmltable 9 ('/ / the root element' entrance passage)

    path number 10 columns id '@id '.

    11 road of varchar2 (30) val '.'

    12           )

    13)

    14 loop

    15 select updatexml (entry, "/ root/item[@id="' | r.id |) ([""] / text()', r.new_val)

    16 comments

    17 double;

    18 end of loop;

    19

    20 dbms_output.put_line (input.getclobval);

    21

    22 end;

    23.

    ABC-1 XYZ-2

    PL/SQL procedure successfully completed

    I spoke earlier of the different techniques:

    How to: Update the XML nodes with values from the same document. Odie Oracle blog

  • Strange behavior with V$ PDB and CDB_SEGMENTS views of Oracle 12 c

    Hello

    I am trying to run a query between the CDB_SEGMENTS and the views V$ PDB on the container ROOT, but I have a strange behavior:

    SQL*Plus: Release 12.1.0.1.0 Production on Fri Sep 6 12:33:25 2013
    
    Copyright (c) 1982, 2013, Oracle. All rights reserved.
    
    
    Connected to:
    Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
    With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
    
    SYS@orcl12c 06.09.2013> show con_id
    
    CON_ID
    ------------------------------
    1
    SYS@orcl12c 06.09.2013> show con_name
    
    CON_NAME
    ------------------------------
    CDB$ROOT
    SYS@orcl12c 06.09.2013> SELECT B.NAME
     2 , A.CON_ID
     3 , A.TABLESPACE_NAME
     4 FROM CDB_SEGMENTS A
     5 INNER JOIN V$PDBS B
     6 ON B.CON_ID=A.CON_ID;
    
    no rows selected
    
    SYS@orcl12c 06.09.2013 12:34:17> SELECT B.NAME
     2 , A.CON_ID
     3 , A.TABLESPACE_NAME
     4 FROM CDB_TABLESPACES A
     5 INNER JOIN V$PDBS B
     6 ON B.CON_ID=A.CON_ID;
    
    NAME CON_ID TABLESPACE_NAME
    ------------------------------ ---------- ------------------------------
    PDB$SEED 2 SYSTEM
    PDB$SEED 2 SYSAUX
    PDB$SEED 2 TEMP
    PDBORCL 3 SYSTEM
    PDBORCL 3 SYSAUX
    PDBORCL 3 TEMP
    PDBORCL 3 USERS
    PDBORCL 3 EXAMPLE
    ...
    
    23 rows selected.
    
    SYS@orcl12c 06.09.2013> SELECT *
     2 FROM TABLE(DBMS_XPLAN.DISPLAY_CURSOR('asa03y45g99zb'));
    
    PLAN_TABLE_OUTPUT
    -----------------------------------------------------------------------------------------------------------------------------------------------------------
    
    SQL_ID asa03y45g99zb, child number 0
    -------------------------------------
    SELECT B.NAME , A.CON_ID , A.TABLESPACE_NAME FROM
    CDB_SEGMENTS A INNER JOIN V$PDBS B ON B.CON_ID=A.CON_ID
    
    Plan hash value: 3590150304
    
    -------------------------------------------------------------------------------------------------------------------------------------------
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Pstart| Pstop | TQ |IN-OUT| PQ Distrib |
    -------------------------------------------------------------------------------------------------------------------------------------------
    | 0 | SELECT STATEMENT | | | | 1 (100)| | | | | |
    | 1 | NESTED LOOPS | | 333 | 14985 | 0 (0)| | | | | |
    |* 2 | FIXED TABLE FULL | X$CON | 2 | 30 | 0 (0)| | | | | |
    | 3 | PX COORDINATOR | | | | | | | | | |
    | 4 | PX SEND QC (RANDOM) | :TQ10000 | 167 | 5010 | 0 (0)| | | Q1,00 | P->S | QC (RAND) |
    | 5 | PX PARTITION LIST AND | | 167 | 5010 | 0 (0)|KEY(AP)|KEY(AP)| Q1,00 | PCWC | |
    |* 6 | FIXED TABLE FIXED INDEX| X$CDBVW$e7cdf8a6 (ind:11) | 167 | 5010 | 0 (0)| | | Q1,00 | PCWP | |
    -------------------------------------------------------------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
     2 - filter(("CON_ID">1 AND "INST_ID"=USERENV('INSTANCE')))
     6 - filter("CON_ID"="CON_ID")
    
    
    25 rows selected.
    
    SYS@orcl12c 06.09.2013> select con_id,count(*) from cdb_segments group by con_id;
    
     CON_ID COUNT(*)
    ---------- ----------
     1 5795
     4 4397
     3 3923
     2 3401
    
    4 rows selected.
    

    Basically, I would like to display the container_name of segments within all PDB files, but the join between CDB_SEGMENTS and views of V$ PDB does not work (lines 20-25) pending the join between CDB_TABLESPACES and V$ PDB works very well (lines 29-34). I've posted the execution plan (lines 50-82).

    You have ideas about this behavior?

    Thank you in advance,

    Arnaud.

    Hello

    Not 100% sure that this is a bug or just something about the way containers works now - however this select seems to work OK:

    SELECT B.NAME, A.CON_ID, A.TABLESPACE_NAME

    OF CDB_SEGMENTS, V$ PDB B

    where to_char (B.CON_ID) = to_char (A.CON_ID)

    See if it works for you too?

    See you soon,.

    Harry

  • Compare 2 different versions of xml and highlite the differences

    Hello

    Currently we have xml and which is displayed on the web page using css style sheets.
    The same xml that we remain majority but with small changes (different say version created after a week).

    We want to be able to follow the differences with the previous version and highlight the differences, when to display in the web page.
    Please let know us if this is possible and how.

    Thank you.

    What is your version of the database? (SELECT * FROM version$ v)

    On 11.2.0.3, update of XQuery can be useful.

    On lower versions, I'd do it like this:

    SQL> WITH sample_data AS (
      2   SELECT xmltype(
      3  '
      4    
      5      7934
      6      MILLER
      7      CLERK
      8      7782
      9      1982-01-23T00:00:00
     10      1300
     11      
     12      10
     13    
     14  ') doc1,
     15  xmltype('
     16    
     17      7934
     18      MILLER
     19      CLERK
     20      7782
     21      xyz
     22      1982-01-23T00:00:00
     23      1300
     24      
     25      10
     26    
     27  ') doc2
     28   FROM dual
     29  )
     30  SELECT XMLSerialize(document
     31           XMLPatch(
     32             doc1
     33           , XMLQuery(
     34              'declare namespace xd = "http://xmlns.oracle.com/xdb/xdiff.xsd"; (: :)
     35               declare function local:copy($itemset as item()*) as item()* {
     36                 for $i in $itemset
     37                  return
     38                   typeswitch($i)
     39                     case element(xd:content) return element {node-name($i)} { {local:copy($i/(node()|@*))} }
     40                     case element() return element {node-name($i)} { local:copy($i/(node()|@*)) }
     41                     default return $i
     42               }; local:copy(*)'
     43               passing XMLDiff(doc1, doc2)
     44               returning content
     45             )
     46           )
     47           as clob indent
     48         )
     49  FROM sample_data
     50  ;
    
    XMLSERIALIZE(DOCUMENTXMLPATCH(
    --------------------------------------------------------------------------------
    
      
        7934
        MILLER
        CLERK
        7782
        
          xyz
        
        1982-01-23T00:00:00
        1300
        
        10
      
    
     
    

    Basically, take us the XMLDiff output and modify it slightly to insert the tag . Then, simply call the XMLPatch function with this newly formed Xdiff document.

    Note that I would normally use XSLT (identity model) to modify Xdiff output but there seems to be a bug when dealing with node Processing, where my using the equivalent of XQuery.

    Published by: odie_63 on September 13. 2012 16:14

  • Inline views

    Hi all

    I have a query that uses inline views and it fails with unable to extend temp error space, space initially temp has 30 GB of space, it went to 50 GB then it also fails.

    If I replace views in line with a view, other than maintaining the opinion, will there be disadvantages as performance.

    Earlier my opinion inline has some data only, now has increased from 15 to 20 times.


    Thank you
    Rambeau

    You have WITH the clause or a sort of query rewrite when optimizer decides to materialise the subquery is possible. Another possibility there is ORDER BY or GROUP BY using the sorting and sorting is not too big, only to sort in memory but also runs out of disk space (tempdb) .c as others already so noted, planning to post request and execution.

    SY.

  • Moving all the newspapers and Materialized View at the schema level using the data pump in

    Hi Experts,

    Please help me on how I can exp/imp all materialized views andMV logs (as are some MVs) only the full scheme of other databases. I want to exclude everything else.

    Concerning
    -Samar-

    Using DBMS_METADATA. Create the following SQL script:

    SET FEEDBACK OFF
    SET SERVEROUTPUT ON FORMAT WORD_WRAPPED
    SET TERMOUT OFF
    SPOOL C:\TEMP\MVIEW.SQL
    DECLARE
        CURSOR V_MLOG_CUR
          IS
            SELECT  DBMS_METADATA.GET_DDL('MATERIALIZED_VIEW_LOG',LOG_TABLE) DDL
              FROM  USER_MVIEW_LOGS;
        CURSOR V_MVIEW_CUR
          IS
            SELECT  DBMS_METADATA.GET_DDL('MATERIALIZED_VIEW',MVIEW_NAME) DDL
              FROM  USER_MVIEWS;
    BEGIN
        DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'SQLTERMINATOR',TRUE);
        FOR V_REC IN V_MLOG_CUR LOOP
          DBMS_OUTPUT.PUT_LINE(V_REC.DDL);
        END LOOP;
        FOR V_REC IN V_MVIEW_CUR LOOP
          DBMS_OUTPUT.PUT_LINE(V_REC.DDL);
        END LOOP;
    END;
    /
    SPOOL OFF
    

    In my case the script is saved as C:\TEMP\MVIEW_GEN. SQL. Now I will create a journal mview and mview in schema SCOTT and run the script above:

    SQL> CREATE MATERIALIZED VIEW LOG ON EMP
      2  /
    
    Materialized view log created.
    
    SQL> CREATE MATERIALIZED VIEW EMP_MV
      2  AS SELECT * FROM EMP
      3  /
    
    Materialized view created.
    
    SQL> @C:\TEMP\MVIEW_GEN
    SQL> 
    

    Run the C:\TEMP\MVIEW_GEN script. SQL generated a C:\TEMP\MVIEW queue. SQL:

      CREATE MATERIALIZED VIEW LOG ON "SCOTT"."EMP"
     PCTFREE 10 PCTUSED 30 INITRANS
    1 MAXTRANS 255 LOGGING
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1
    MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL
    DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
      TABLESPACE "USERS" 
    
    WITH PRIMARY KEY EXCLUDING NEW VALUES;
    
      CREATE MATERIALIZED VIEW "SCOTT"."EMP_MV" ("EMPNO", "ENAME", "JOB", "MGR",
    "HIREDATE", "SAL", "COMM", "DEPTNO")
      ORGANIZATION HEAP PCTFREE 10 PCTUSED 40
    INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
      STORAGE(INITIAL 65536 NEXT 1048576
    MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
    BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
      TABLESPACE
    "USERS"
      BUILD IMMEDIATE
      USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 
    
    STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
    
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE
    DEFAULT CELL_FLASH_CACHE DEFAULT)
      TABLESPACE "USERS"
      REFRESH FORCE ON
    DEMAND
      WITH PRIMARY KEY USING DEFAULT LOCAL ROLLBACK SEGMENT
      USING ENFORCED
    CONSTRAINTS DISABLE QUERY REWRITE
      AS SELECT "EMP"."EMPNO"
    "EMPNO","EMP"."ENAME" "ENAME","EMP"."JOB" "JOB","EMP"."MGR"
    "MGR","EMP"."HIREDATE" "HIREDATE","EMP"."SAL" "SAL","EMP"."COMM"
    "COMM","EMP"."DEPTNO" "DEPTNO" FROM "EMP" "EMP";
                                   
    

    Now, you can run this on the database. You may need to adjust the tablespace and storage clauses. Or you can add more DBMS_METADATA. SET_TRANSFORM_PARAM calls to C:\TEMP\MVIEW_GEN. SQL to force DBMS_METADATA not to include the tablespace or / and the terms of storage.

    SY.

  • Need help to read a _fmb. XML and write the properties of the element to a table

    We want to retrieve all the properties of elements of forms at a table.
    Table has this format:
    Describing oracle_forms_item_list....
    NAME                            Null?     Type
    ------------------------------- --------- -----
    FORM_NAME                       NOT NULL  VARCHAR2(100)
    ITEM_NAME                       NOT NULL  VARCHAR2(50)
    ITEM_TYPE                       NOT NULL  VARCHAR2(50)
    PROPERTY                        NOT NULL  VARCHAR2(50)
    PROPERTY_VALUE                            VARCHAR2(500)
    We want to get all D_e_p_a_r_t_m_e_n_t_s.fmb items (blocks, paintings, text etc.). So first convert us it to XML and we get the D_e_p_a_r_t_m_e_n_t_s_fmb.xml file which is shown below.
    <?xml version = '1.0' encoding = 'UTF-8'?>
    <Module version="101020002" xmlns="http://xmlns.oracle.com/Forms">
       <FormModule Name="D_E_P_A_R_T_M_E_N_T_S" ConsoleWindow="WINDOW1" DirtyInfo="true" MenuModule="DEFAULT&amp;SMARTBAR" Title="MODULE5">
          <Coordinate CharacterCellWidth="7" CoordinateSystem="Real" CharacterCellHeight="14" RealUnit="Point" DefaultFontScaling="true"/>
          <Alert Name="ALERT6" DirtyInfo="true" DefaultAlertButton="Button 2" AlertMessage="Do you want to save ???" Button2Label="No" AlertStyle="Caution" Title="Saving........................... &lt;>" Button1Label="Yes"/>
          <Block Name="DEPT" ScrollbarTabPageName="" DirtyInfo="true" QueryDataSourceName="dept" ScrollbarWidth="14" ScrollbarYPosition="39" ShowScrollbar="true" ScrollbarCanvasName="CANVAS4" ScrollbarLength="70" RecordsDisplayCount="5" ScrollbarXPosition="237">
             <Item Name="DEPTNO" DirtyInfo="true" Height="14" PromptAlign="Center" XPosition="14" Width="27" ColumnName="DEPTNO" DataType="Number" YPosition="39" PromptDisplayStyle="First Record" ItemsDisplay="0" MaximumLength="3" PromptAttachmentEdge="Top" ItemType="Text Item" TabPageName="" CanvasName="CANVAS4" Prompt="Deptno"/>
             <Item Name="DNAME" DirtyInfo="true" Height="14" PromptAlign="Center" XPosition="41" Width="101" ColumnName="DNAME" YPosition="39" Tooltip="Dep name goooes here." DataLengthSemantics="BYTE" Hint="Entter the department name" PromptDisplayStyle="First Record" ItemsDisplay="0" MaximumLength="14" PromptAttachmentEdge="Top" ItemType="Text Item" TabPageName="" CanvasName="CANVAS4" Prompt="Dname"/>
             <Item Name="LOC" DirtyInfo="true" Height="14" PromptAlign="Center" XPosition="142" Width="95" ColumnName="LOC" YPosition="39" DataLengthSemantics="BYTE" PromptDisplayStyle="First Record" ItemsDisplay="0" MaximumLength="13" PromptAttachmentEdge="Top" ItemType="Text Item" TabPageName="" CanvasName="CANVAS4" Prompt="Loc"/>
             <DataSourceColumn Type="Query" DSCType="NUMBER" DSCNochildren="false" DSCLength="0" DSCPrecision="2" DSCName="DEPTNO" DSCScale="0" DSCMandatory="false"/>
             <DataSourceColumn Type="Query" DSCType="VARCHAR2" DSCNochildren="false" DSCLength="14" DSCPrecision="0" DSCName="DNAME" DSCScale="0" DSCMandatory="false"/>
             <DataSourceColumn Type="Query" DSCType="VARCHAR2" DSCNochildren="false" DSCLength="13" DSCPrecision="0" DSCName="LOC" DSCScale="0" DSCMandatory="false"/>
          </Block>
          <Canvas Name="CANVAS4" ViewportHeight="324" DirtyInfo="true" Height="324" WindowName="WINDOW1" Width="540" ViewportWidth="540" CanvasType="Content">
             <Graphics Name="FRAME5" GraphicsText="" FrameTitleOffset="14" Height="108" VerticalMargin="14" GraphicsFontColor="" GraphicsFontSpacing="Ultradense" Width="251" GraphicsFontSize="0" GraphicsFontWeight="Ultralight" StartPromptOffset="7" FillPattern="none" GraphicsFontColorCode="0" HorizontalObjectOffset="0" EdgeBackColor="white" FrameTitle="Departments" ShowScrollbar="true" RecordsDisplayCount="5" LayoutStyle="Tabular" DirtyInfo="true" XPosition="7" Bevel="Inset" GraphicsFontStyle="0" ScrollbarWidth="14" HorizontalMargin="7" FrameTitleSpacing="7" EdgePattern="solid" YPosition="15" GraphicsType="Frame" GraphicsFontName="" LayoutDataBlockName="DEPT"/>
          </Canvas>
          <ProgramUnit Name="ASK_FROM_USER" ProgramUnitType="Function" ProgramUnitText="FUNCTION ask_from_user RETURN BOOLEAN IS&amp;#10; v_button number;&amp;#10;BEGIN&amp;#10;  v_button := SHOW_ALERT('ALERT6');&amp;#10;  &amp;#10;  if v_button = ALERT_BUTTON2 THEN&amp;#10;       RETURN false;&amp;#10;  ELSE&amp;#10;       RETURN TRUE;&amp;#10;  END IF;&amp;#10;END;"/>
          <Trigger Name="POST-DATABASE-COMMIT" TriggerText="/*&amp;#10;   Created by ABC de Silva&amp;#10;   &lt;&lt;&lt;&lt;&lt;..>> &amp;#10;   testing for special characters &lt; rock &amp; roll &amp;#10;*/&amp;#10;BEGIN&amp;#10;     MESSAGE('*** Records successfully &lt;&lt;&lt;> commmited to the DB. ***');&amp;#10;     PAUSE;&amp;#10;END;" DirtyInfo="true"/>
          <Window Name="WINDOW1" Height="324" Width="540"/>
       </FormModule>
    </Module>
    Now, we want to read this file with UTL_FILE (in a PL/SQL stored procedure) and fill in the chart above like this:
    FORM_NAME                  ITEM_NAME   ITEM_TYPE  PROPERTY         PROPERTY_VALUE                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
    ----------------------------------------------------------------------------------------------------------
    D_e_p_a_r_t_m_e_n_t_s.fmb  ALERT6      Alert      Title            Saving........................... <>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
    D_e_p_a_r_t_m_e_n_t_s.fmb  DEPTNO      Text Item  Prompt           Dname                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
    D_e_p_a_r_t_m_e_n_t_s.fmb  DEPTNO      Text Item  MaximumLength    3                                                                                                                                                                                                                                                                                                                                     
    It's, I went through Google, nobody can give a complete solution. All are partial solutions.

    Any help will greatly be apprectiated.

    Published by: Channa on 30 Sep 2011 06:31

    Here goes:

    select x1.item_name
         , x1.item_type
         , x2.property
         -- to convert back entities such as 
     to their character values :
         , utl_i18n.unescape_reference(x2.property_value) as property_value
         -- parent information :
         , x1.parent_item_name
         , x1.parent_item_type
    from xmltable(
           xmlnamespaces(default 'http://xmlns.oracle.com/Forms', 'http://xmlns.oracle.com/Forms' as "def")
         , 'for $i in /Module/descendant::*[@def:Name]
            return element item {
              attribute item_name {data($i/@def:Name)}
            , attribute item_type {local-name($i)}
            , attribute parent_item_name {data($i/parent::*/@def:Name)}
            , attribute parent_item_type {local-name($i/parent::*)}
            , $i
            }'
           passing xmltype(bfilename('TEST_DIR','module2.xml'), nls_charset_id('AL32UTF8'))
           columns item_name         varchar2(50) path '@item_name'
                 , item_type         varchar2(50) path '@item_type'
                 , parent_item_name  varchar2(50) path '@parent_item_name'
                 , parent_item_type  varchar2(50) path '@parent_item_type'
                 , item              xmltype      path '.'
         ) x1
       , xmltable(
           xmlnamespaces(default 'http://xmlns.oracle.com/Forms', 'http://xmlns.oracle.com/Forms' as "def")
         , 'for $i in /item/*/attribute::def:*
            let $propname := local-name($i)
            where $propname != "Name"
            return element p {
              element name {$propname}
            , element value {data($i)}
            }'
           passing x1.item
           columns property       varchar2(50)  path 'name'
                 , property_value varchar2(500) path 'value'
        ) x2
    ;
    

    To make it easier, instead of calculating an ID, the information of the parent are given as (parent_name, parent_type).

Maybe you are looking for