(urgent) How to make sumarize query against XMLType?

Hello,
i have xml document like this
<List>
<Item>
<A>10</A>
<B>554</B>
<C>25.5.2005</C>
</Item>
<Item>
<A>20</A>
<B>49</B>
<C>26.5.2005</C>
</Item>
<Item>
<A>30</A>
<B>184</B>
<C>27.5.2005</C>
</Item>
</List>
in xmltype variable (not table column) and i need e.g. sum (or count or something like that) values in xpath /List/Item/B in one document.
Is there some quick and elegant way to do this?
Thanks for quick help.

Maybe the below will help.
Did you look at building a view over the xmltype extracting the values into a relational type view, then using the view to sum up the values.
Jonthan Gennick has an article on the Oracle OTN website with the below code.
CREATE VIEW cd_master (Title, Artist, Website, Description) AS
SELECT extractValue(value(x),'/CD/Title'),
extractValue(value(x),'/CD/Artist'),
extractValue(value(x),'/CD/Website'),
extractValue(value(x),'/CD/Description')
FROM CD331_TAB x;
CREATE INDEX by_artist ON CD331_TAB x (
extractValue(value(x),'/CD/Artist'));
ANALYZE TABLE cd331_tab COMPUTE STATISTICS FOR TABLE;
ANALYZE INDEX by_artist COMPUTE STATISTICS;

Similar Messages

  • How to make af: query (ResultComponentId) has two target values?

    hello all :D
    i'm newbie in jdev, i have little problem with af:query.
    how to make af: query (ResultComponentId) has two target values?
    thx
    agungdmt :D

    I think you can simply set the second target control's partialTrigger to the af:query.
    and access to the same binding attribute as your first target. (e.g.: if you have 2 target tables, set the value to #{bindings.XxxxxVO1.collectionModel})
    Samson Fu

  • How to make a query to list out Journal voucher that hasn't been posted

    Hi, do you know how to make a query to list out Journal voucher that hasn't been posted?
    By what code name identify that?
    Thanks.
    Raymond
    Edited by: Rui Pereira on Aug 6, 2008 3:57 PM

    jack,
    there is no link with OBTD to OJDT and JDT1.
    voucher number in obdt is different,
    after posting voucher is saved as journal entry seperate
    number is generated.
    you can link OACT,OCRD WITH OJDT,JDT1.
    Jeyakanthan

  • How to make linkage query In Data Model for search

    I want to make an linkage query as a condition for my  report in BI Publisher. how to make the linkage in Date Model ?

    This is the forum for SQL Developer, not for general SQL or PL/SQL questions.
    Please repost this in the SQL and PL/SQL forum.

  • Very URGENT -- How to make keyboard print

    This is very urgent. How to make the keyboard print?

    Here is the code. It is supposed to make the keyboard type something.
    This is URGENT.
    public class KeyBoarder
         private int keyPressed;
         public KeyBoarder()
              System.out.println("Welcome to keyboard");
         private void print()
              System.out.println("Keyboarder has printed");
         public static void main(String args[])
              KeyBoarder board = new KeyBoarder();
              board.print();

  • How To Make Search Query Showing the Result As List of Buttons.

    Can some one give me an idea how to start to make a Search Query showing the results as list of buttons.. i have already have my buttons with names. i just dont know how to make a search query.
    this is my on screen keyboard i made..
    im making a system that the result were a list of buttons.. showing like this
    This was supposed to be the output of the query that i need to do..
    Please help me.. i just need a idea or tips how to make this one.

    Here is code I posted recently for another question
    Public Class Form1
    Const BUTTON_SIZE As Integer = 20
    Const SPACE As Integer = 5
    Sub New()
    ' This call is required by the Windows Form Designer.
    InitializeComponent()
    ' Add any initialization after the InitializeComponent() call.
    Dim buttons As New List(Of List(Of MyRadioButton))
    For row = 1 To 6
    Dim newRow As New List(Of MyRadioButton)
    buttons.Add(newRow)
    For col = 1 To 6
    Dim button As New MyRadioButton()
    button.row = row
    button.col = col
    button.Height = BUTTON_SIZE
    button.Width = BUTTON_SIZE
    button.Left = col * (BUTTON_SIZE + SPACE)
    button.Top = row * (BUTTON_SIZE + SPACE)
    button.Name = String.Format("radGr1{0}_{1}", row.ToString(), col.ToString())
    Me.Controls.Add(button)
    newRow.Add(button)
    AddHandler button.CheckedChanged, AddressOf Radio_Change
    Next col
    Next row
    End Sub
    Private Sub Radio_Change(ByVal sender As Object, ByVal e As System.EventArgs)
    Dim button As MyRadioButton = CType(sender, MyRadioButton)
    Dim row As Integer = button.row
    Dim col As Integer = button.col
    End Sub
    End Class
    Public Class MyRadioButton
    Inherits RadioButton
    Public row As Integer
    Public col As Integer
    End Class
    jdweng

  • Why Is Query Against XMLTYPE Table ACME_CUST Doing A Full Table Scan?

    On our Oracle Database 11g Enterprise Edition Release 11.2.0.1.0, we have a query against against a 25,214 record XMLTYPE ACME_CUST table.
    SELECT rownum   AS seq,
          EID  AS eid,
          SUBSTR(CUST_ID, 1, INSTR(CUST_ID, '|')-1) AS tgt_acme_customer_id,
          SUBSTR(CUST_ID, INSTR(CUST_ID, '|')   +1) AS src_acme_customer_id_list
        FROM
          (SELECT ac.eid EID,
            listagg(ac.acme_cust_id, '|') WITHIN GROUP (
          ORDER BY ac.acme_cust_id, ac.acme_cust_id) CUST_ID
          FROM ACME_CUST ac
          GROUP BY ac.eid
          HAVING COUNT(ac.acme_cust_id)>1)Explain plan shows:
    Select Statement
    Count
    VIEW
    FILTER
    Filter Predicates
    COUNT(*) > 1
    SORT GROUP BY
    TABLE ACCESS ACME_CUST FULL
    The ACME_CUST Table has a virtual column defined on acme_cust_id along with a corresponding index. This filed is also defined as a primary key.
    Here is the table definitiion and associated statements:
    CREATE
      TABLE "N98991"."ACME_CUST" OF XMLTYPE
        CONSTRAINT "ACME_CUST_ID_PK" PRIMARY KEY ("ACME_CUST_ID") USING INDEX
        PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 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 "ACME_DEV" ENABLE
      XMLTYPE STORE AS SECUREFILE BINARY XML
        TABLESPACE "ACME_DEV" ENABLE STORAGE IN ROW CHUNK 8192 CACHE READS LOGGING
        NOCOMPRESS KEEP_DUPLICATES STORAGE(INITIAL 106496 NEXT 1048576 MINEXTENTS 1
        MAXEXTENTS 2147483645 PCTINCREASE 0 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT
        CELL_FLASH_CACHE DEFAULT)
      ALLOW NONSCHEMA ALLOW ANYSCHEMA VIRTUAL COLUMNS
        "EID" AS (CAST(SYS_XQ_UPKXML2SQL(SYS_XQEXVAL(XMLQUERY(
        'declare default element namespace "http://www.cigna.com/acme/domains/customer/customerprofile/2011/11"; (::)                              
    /customerProfile/@eid'
        PASSING BY VALUE SYS_MAKEXML(128,"XMLDATA") RETURNING CONTENT ),0,0,
        16777216,0),50,1,2) AS VARCHAR2(15))),
      *bold*  "ACME_CUST_ID" AS (CAST(SYS_XQ_UPKXML2SQL(SYS_XQEXVAL(XMLQUERY(
        'declare default element namespace "http://www.cigna.com/acme/domains/customer/customerprofile/2011/11"; (::)                              
    /customerProfile/@id' *bold*
        PASSING BY VALUE SYS_MAKEXML(128,"XMLDATA") RETURNING CONTENT ),0,0,
        16777216,0),50,1,2) AS VARCHAR2(50))),
        "CRET_DT" AS (SYS_EXTRACT_UTC(CAST(TO_TIMESTAMP_TZ(SYS_XQ_UPKXML2SQL(
        SYS_XQEXVAL(XMLQUERY(
        'declare default element namespace "http://www.cigna.com/acme/domains/customer/customerprofile/2011/11"; (::)                                                                                                      
    /customerProfile/@create_dt'
        PASSING BY VALUE SYS_MAKEXML(128,"XMLDATA") RETURNING CONTENT ),0,0,
        16777216,0),50,1,2),'SYYYY-MM-DD"T"HH24:MI:SS.FFTZH:TZM') AS TIMESTAMP
    WITH
      TIME ZONE)))
      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 "ACME_DEV" ;
    CREATE
      INDEX "N98991"."ACME_CST_CRET_DT_IDX" ON "N98991"."ACME_CUST"
        "CRET_DT"
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 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 "ACME_DEV" ;
    CREATE
      INDEX "N98991"."ACME_CST_EID_IDX" ON "N98991"."ACME_CUST"
        "EID"
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 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 "ACME_DEV" ;
    *bold*CREATE UNIQUE INDEX "N98991"."ACME_CUST_ID_PK" ON "N98991"."ACME_CUST"
        "ACME_CUST_ID"
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE *bold*
        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 "ACME_DEV" ;
      CREATE
        INDEX "N98991"."ACME_CUST_XMLINDEX_IX" ON "N98991"."ACME_CUST"
          OBJECT_VALUE
        INDEXTYPE IS "XDB"."XMLINDEX" PARAMETERS
          'XMLTABLE ACME_CUST_IDX_TAB XMLNamespaces (''http://www.cigna.com/acme/domains/commoncontact/2011/11'' as "cm",  default ''http://www.cigna.com/acme/domains/customer/customerprofile/2011/11''),      
    ''/customerProfile''       
    columns      
    DOB date  PATH ''personInformation/cm:birthDate'',      
    FIRSTNAME varchar2(40)    PATH ''name/cm:givenName'',      
    LASTNAME varchar2(40)    PATH ''name/cm:surName'',      
    SSN varchar2(30)    PATH ''identifiers/ssn'',      
    MEMBERINFOS XMLType path ''memberInfos/memberInfo'' VIRTUAL       
    XMLTable acme_cust_lev2_idx_tab XMLNAMESPACES(default ''http://www.cigna.com/acme/domains/customer/customerprofile/2011/11''),      
    ''/memberInfo'' passing MEMBERINFOS         
    columns         
    ami varchar2(40) PATH ''ami'',        
    subscId varchar2(50) PATH ''clientRelationship/subscriberInformation/subscriberId'',        
    employeeId varchar2(50) PATH ''systemKeys/employeeId'',        
    clientId varchar2(50) PATH ''clientRelationship/clientId''      
    CREATE UNIQUE INDEX "N98991"."SYS_C00384339" ON "N98991"."ACME_CUST"
        "SYS_NC_OID$"
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 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 "ACME_DEV" ;
    CREATE UNIQUE INDEX "N98991"."SYS_IL0000649948C00003$$" ON "N98991"."ACME_CUST"
        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 "ACME_DEV" PARALLEL (DEGREE 0 INSTANCES 0) ;Why isn't the unique index ACME_CUST_ID_PK on the virtual column ACME_CUST_ID being used in the explain plan?
    Any input would be much appreciated, as really stumped here.
    Regards,
    Rick

    Hi Richard,
    The 10053 event appears overkill for this situation. What's the big deal?
    Set the event, run the query, unset the event, check the trace file, that's all.
    It's not overkill if it helps you understanding what happens and why an index is of no use in this situation.
    Tried the /*+ INDEX_FFS(ACME_CUST_ID_PK) */ hint in the 'nested' query.Not sure what nested query you're referring to, so if I misunderstood what you mean, just ignore the following comment.
    From what you posted earlier, it looks like you're talking about this part :
    listagg(ac.acme_cust_id,'|') WITHIN GROUP (
    ORDER BY ac.acme_cust_id,ac.acme_cust_id) CUST_IDThat's not a nested query, it's a projection. All the main work (retrieving rows) has already been done when it comes to this part.
    May just have to accept the query performance as it is...Maybe you can try something else.
    See the document : Oracle XML DB : Best Practices, page 15 ex. 8 :
    When there are multiple scalar values that need to be grouped or ordered, it is better to write it
    with XMLTable construct that projects out all columns to be ordered or grouped as shown
    below.Here's an example close to your actual requirement :
    Connected to:
    Oracle Database 11g Express Edition Release 11.2.0.2.0 - Production
    SQL> create table xtab_cols of xmltype
      2  xmltype store as securefile binary xml;
    Table created.
    SQL> insert /*+ append */ into xtab_cols
      2  select xmlelement("ROW",
      3           xmlforest(
      4            TABLE_NAME, COLUMN_NAME, DATA_TYPE, DATA_TYPE_MOD, DATA_TYPE_OWNER,
      5            DATA_LENGTH, DATA_PRECISION, DATA_SCALE, NULLABLE, COLUMN_ID,
      6            DEFAULT_LENGTH, NUM_DISTINCT, LOW_VALUE, HIGH_VALUE,
      7            DENSITY, NUM_NULLS, NUM_BUCKETS, LAST_ANALYZED, SAMPLE_SIZE,
      8            CHARACTER_SET_NAME, CHAR_COL_DECL_LENGTH,
      9            GLOBAL_STATS, USER_STATS, AVG_COL_LEN, CHAR_LENGTH, CHAR_USED,
    10            V80_FMT_IMAGE, DATA_UPGRADED, HISTOGRAM
    11           )
    12         )
    13  from dba_tab_cols
    14  where owner = 'SYS'
    15  ;
    57079 rows created.
    SQL> commit;
    Commit complete.
    SQL> set long 1000
    SQL> set pages 100
    SQL> select xmlserialize(document object_value) from xtab_cols where rownum = 1;
    XMLSERIALIZE(DOCUMENTOBJECT_VALUE)
    <ROW>
      <TABLE_NAME>ACCESS$</TABLE_NAME>
      <COLUMN_NAME>D_OBJ#</COLUMN_NAME>
      <DATA_TYPE>NUMBER</DATA_TYPE>
      <DATA_LENGTH>22</DATA_LENGTH>
      <NULLABLE>N</NULLABLE>
      <COLUMN_ID>1</COLUMN_ID>
      <NUM_DISTINCT>7454</NUM_DISTINCT>
      <LOW_VALUE>C2083A</LOW_VALUE>
      <HIGH_VALUE>C3031D18</HIGH_VALUE>
      <DENSITY>,000134156157767642</DENSITY>
      <NUM_NULLS>0</NUM_NULLS>
      <NUM_BUCKETS>1</NUM_BUCKETS>
      <LAST_ANALYZED>2012-01-28</LAST_ANALYZED>
      <SAMPLE_SIZE>34794</SAMPLE_SIZE>
      <GLOBAL_STATS>YES</GLOBAL_STATS>
      <USER_STATS>NO</USER_STATS>
      <AVG_COL_LEN>5</AVG_COL_LEN>
      <CHAR_LENGTH>0</CHAR_LENGTH>
      <V80_FMT_IMAGE>NO</V80_FMT_IMAGE>
      <DATA_UPGRADED>YES</DATA_UPGRADED>
      <HISTOGRAM>NONE</HISTOGRAM>
    </ROW>
    SQL> exec dbms_stats.gather_table_stats(user, 'XTAB_COLS');
    PL/SQL procedure successfully completed.
    SQL> set autotrace traceonly
    SQL> set timing on
    SQL> set lines 120
    SQL> select x.table_name
      2       , listagg(x.column_name, ',') within group (order by column_id)
      3  from xtab_cols t
      4     , xmltable('/ROW' passing t.object_value
      5        columns table_name  varchar2(30) path 'TABLE_NAME'
      6              , column_name varchar2(30) path 'COLUMN_NAME'
      7              , column_id   number       path 'COLUMN_ID'
      8       ) x
      9  group by x.table_name
    10  ;
    4714 rows selected.
    Elapsed: 00:00:08.25
    Execution Plan
    Plan hash value: 602782846
    | Id  | Operation           | Name      | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT    |           |   466M|   101G|  1580K  (3)| 05:16:04 |
    |   1 |  SORT GROUP BY      |           |   466M|   101G|  1580K  (3)| 05:16:04 |
    |   2 |   NESTED LOOPS      |           |   466M|   101G|  1552K  (1)| 05:10:32 |
    |   3 |    TABLE ACCESS FULL| XTAB_COLS | 57079 |    12M|   408   (1)| 00:00:05 |
    |   4 |    XPATH EVALUATION |           |       |       |            |          |
    Statistics
              9  recursive calls
              1  db block gets
           1713  consistent gets
              0  physical reads
             96  redo size
         773516  bytes sent via SQL*Net to client
           3873  bytes received via SQL*Net from client
            316  SQL*Net roundtrips to/from client
              1  sorts (memory)
              0  sorts (disk)
           4714  rows processedAnd of course, even better after adding a structured XML index (4714 rows fetched in 1s) :
    SQL> CREATE INDEX xtab_cols_sxi ON xtab_cols (OBJECT_VALUE) INDEXTYPE IS XDB.XMLIndex
      2  PARAMETERS (
      3  q'#XMLTable my_xtab
      4  '/ROW'
      5  columns table_name varchar2(30) path 'TABLE_NAME'
      6        , column_name varchar2(30) path 'COLUMN_NAME'
      7        , column_id number path 'COLUMN_ID' #');
    Index created.
    Elapsed: 00:00:13.42
    SQL> select x.table_name
      2       , listagg(x.column_name, ',') within group (order by column_id)
      3  from xtab_cols t
      4     , xmltable('/ROW' passing t.object_value
      5        columns table_name  varchar2(30) path 'TABLE_NAME'
      6              , column_name varchar2(30) path 'COLUMN_NAME'
      7              , column_id   number       path 'COLUMN_ID'
      8       ) x
      9  group by x.table_name
    10  ;
    4714 rows selected.
    Elapsed: 00:00:01.00
    Execution Plan
    Plan hash value: 3303494605
    | Id  | Operation          | Name    | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT   |         | 57520 |  3201K|   174   (3)| 00:00:03 |
    |   1 |  SORT GROUP BY     |         | 57520 |  3201K|   174   (3)| 00:00:03 |
    |   2 |   TABLE ACCESS FULL| MY_XTAB | 57520 |  3201K|   171   (1)| 00:00:03 |
    Note
       - dynamic sampling used for this statement (level=2)
    Statistics
            297  recursive calls
              1  db block gets
            989  consistent gets
              0  physical reads
            176  redo size
         773516  bytes sent via SQL*Net to client
           3873  bytes received via SQL*Net from client
            316  SQL*Net roundtrips to/from client
             21  sorts (memory)
              0  sorts (disk)
           4714  rows processed

  • Query against XMLType

    I'm hung up on something that I suspect is very easy, but I have little experience working with XML in the database and think I've just stared at it too long.
    I have an XML document (fragment below) stored as an XMLType in a 10g R2 database table and I want to return the following result set from a query against the document:
    PAGE_ID PAGE_SUBMISSION_FIELD
    21 F39EF21
    21 F85FG3E
    21 F73EF58
    21 FA4939F
    22 FDE77A4
    22 FF3AD33
    Here is a fragment of the XML document:
    <root-interface>
    <page-group>
    <display-page validation-state="new">
    <id>21</id>
    <page-submission-fields>
    <page-submission-field>F39EF21</page-submission-field>
    <page-submission-field>F85FG3E</page-submission-field>
    <page-submission-field>F73EF58</page-submission-field>
    <page-submission-field>FA4939F</page-submission-field>
    </page-submission-fields>
    </display-page>
    <display-page validation-state="new">
    <id>22</id>
    <page-submission-fields>
    <page-submission-field>FDE77A4</page-submission-field>
    <page-submission-field>FF3AD33</page-submission-field>
    </page-submission-fields>
    </display-page>
    </page-group>
    </root-interface>
    Here is the table in which it is stored:
    desc cms_session_interfaces
    Name Null? Type
    SESSION_ID NOT NULL NUMBER
    INTERFACE_ID NOT NULL NUMBER
    CREATED NOT NULL DATE
    LAST_ACCESSED DATE
    INTERFACE_XML SYS.XMLTYPE
    Here is a close as I've come with a query:
    select extract(value(display_pages), '//id/text()').getStringVal() page_id,
    extract(value(display_pages), '//page-submission-fields/page-submission-field') page_submission_field
    from cms_session_interfaces csi,
    table(xmlsequence(extract(csi.interface_xml, '//root-interface/page-group/display-page'))) display_pages
    where csi.session_id = 41
    and csi.interface_id = 596
    (the specified session_id and interface_id are just for testing purposes)
    This returns two rows consisting of the PAGE_ID and an object of XMLType containing the page-submission fields. Almost there, but not quite; any suggestions would be appreciated.

    As Marco said, xmltable is very handy:
    SQL> with cms_session_interfaces as (
      2  select XMLType('
      3  <root-interface>
      4    <page-group>
      5      <display-page validation-state="new">
      6        <id>21</id>
      7        <page-submission-fields>
      8          <page-submission-field>F39EF21</page-submission-field>
      9          <page-submission-field>F85FG3E</page-submission-field>
    10          <page-submission-field>F73EF58</page-submission-field>
    11          <page-submission-field>FA4939F</page-submission-field>
    12        </page-submission-fields>
    13      </display-page>
    14      <display-page validation-state="new">
    15        <id>22</id>
    16        <page-submission-fields>
    17          <page-submission-field>FDE77A4</page-submission-field>
    18          <page-submission-field>FF3AD33</page-submission-field>
    19        </page-submission-fields>
    20      </display-page>
    21          </page-group>
    22  </root-interface>') interface_xml
    23  from dual)
    24  select page.id,fields.field
    25  from cms_session_interfaces csi,
    26  xmltable('//root-interface/page-group/display-page'
    27   passing interface_xml
    28   columns
    29    id varchar2(10) path 'id',
    30    page_fields xmltype path 'page-submission-fields') page,
    31  xmltable('/page-submission-fields/page-submission-field'
    32   passing page_fields
    33   columns
    34    field varchar2(25) path '.') fields
    35  /
    ID         FIELD
    21         F39EF21
    21         F85FG3E
    21         F73EF58
    21         FA4939F
    22         FDE77A4
    22         FF3AD33
    6 rows selected.Best regards
    Maxim

  • How to use one query against multiple table and recieve one report?

    I have duplicate tables, (except for their names of course) with commodities prices. They have the same column headings, but the data is different of course. I have a query that gives me a certain piece of information I am looking for but now I need to run this query against every table. I will do this every day as well, to see if the buying criteria is met. There are alot of tables though (256). Is there a way to say run query in all tables and return the results in one place? Thanks for your help.

    hey
    a. the all 256 tables whuld be one big partitoned table
    b. you can use all_tables in order to write a select that will write the report for you:
    SQL> set head off
    SQL> select 'select * from (' from dual
      2  union all
      3  select 'select count(*) from ' || table_name || ' union all ' from a
      4  where table_name like 'DB%' AND ROWNUM <= 3
      5  union all
      6  select ')' from dual;
    select * from (
    select count(*) from DBMS_LOCK_ALLOCATED union all
    select count(*) from DBMS_ALERT_INFO union all
    select count(*) from DBMS_UPG_LOG$ union all
    remove the last 'union all', and tun the generated quary -
    SQL> set head on
    SQL> select * from (
      2  select count(*) from DBMS_LOCK_ALLOCATED union all
      3  select count(*) from DBMS_ALERT_INFO union all
      4  select count(*) from DBMS_UPG_LOG$
      5  );
      COUNT(*)
             0
             0
             0
    Amiel

  • How to make dynamic query using DBMS_SQL variable column names

    First of all i will show a working example of what i intend to do with "EXECUTE IMMEDIATE":
    (EXECUTE IMMEDIATE has 32654 Bytes limit, which isn't enough for me so i'm exploring other methods such as DBMS_SQL)
    -------------------------------------------------CODE-----------------------------------
    create or replace PROCEDURE get_dinamic_query_content
    (query_sql IN VARCHAR2, --any valid sql query ('SELECT name, age FROM table') 
    list_fields IN VARCHAR2) --list of the columns name belonging to the query (  arr_list(1):='name';   arr_list(2):='age';
    -- FOR k IN 1..arr_list.count LOOP
    -- list_fields := list_fields || '||content.'||arr_list(k)||'||'||'''~cs~'''; )
    AS
    sql_stmt varchar (30000);
    BEGIN
                   sql_stmt :=
    'DECLARE
         counter NUMBER:=0;     
    auxcontent VARCHAR2(30000);     
         CURSOR content_cursor IS '|| query_sql ||';
         content content_cursor%rowtype;     
         Begin
              open content_cursor;
              loop
                   fetch content_cursor into content;
                   exit when content_cursor%notfound;
                   begin                              
                        auxcontent := auxcontent || '||list_fields||';                    
                   end;
                   counter:=counter+1;     
              end loop;
              close content_cursor;
              htp.prn(auxcontent);
         END;';
    EXECUTE IMMEDIATE sql_stmt;
    END;
    -------------------------------------------------CODE-----------------------------------
    I'm attepting to use DBMS_SQL to perform similar instructions.
    Is it possible?

    Hi Pedro
    You need to use DBMS_SQL here because you don't know how many columns your query is going to have before runtime. There are functions in DBMS_SQL to get information about the columns in your query - all this does is get the name.
    SQL&gt; CREATE OR REPLACE PROCEDURE get_query_cols(query_in IN VARCHAR2) AS
    2 cur PLS_INTEGER;
    3 numcols NUMBER;
    4 col_desc_table dbms_sql.desc_tab;
    5 BEGIN
    6 cur := dbms_sql.open_cursor;
    7 dbms_sql.parse(cur
    8 ,query_in
    9 ,dbms_sql.native);
    10 dbms_sql.describe_columns(cur
    11 ,numcols
    12 ,col_desc_table);
    13 FOR ix IN col_desc_table.FIRST .. col_desc_table.LAST LOOP
    14 dbms_output.put_line('Column ' || ix || ' is ' ||
    15 col_desc_table(ix).col_name);
    16 END LOOP;
    17 dbms_sql.close_cursor(cur);
    18 END;
    19 /
    Procedure created.
    SQL&gt; exec get_query_cols('SELECT * FROM DUAL');
    Column 1 is DUMMY
    PL/SQL procedure successfully completed.
    SQL&gt; exec get_query_cols('SELECT table_name, num_rows FROM user_tables');
    Column 1 is TABLE_NAME
    Column 2 is NUM_ROWS
    PL/SQL procedure successfully completed.
    SQL&gt; exec get_query_cols('SELECT column_name, data_type, low_value, high_value FROM user_tab_cols');
    Column 1 is COLUMN_NAME
    Column 2 is DATA_TYPE
    Column 3 is LOW_VALUE
    Column 4 is HIGH_VALUE
    PL/SQL procedure successfully completed.I've just written this as a procedure that prints out the column names using dbms_output - I guess you're going to do something different with the result - maybe returning a collection, which you'll then parse through in Apex and print the output on the screen - this is just to illustrate the use of dbms_sql.
    best regards
    Andrew
    UK

  • How to make this query

    hi,
    i have 2 tables emp1 & emp2
    emp1 consist
    empno month amt
    001 201002 200
    001 201003 100
    emp2 consist
    empno month amt
    001 201001 100
    001 201002 200
    001 201003 100
    i want to make a query on emp1 table where i want to show amt according to month ,if data is not available in emp1 table then only then it should take data from emp2 table ,if emp2 has that month data o/w 0.
    my output should be like this
    empno month amt
    001 201001 100
    001 201002 200
    001 201003 100
    regards

    May be....
    SQL> WITH emp1 AS (SELECT '001' empno,'201002' mon,200 amt FROM DUAL UNION ALL
      2                SELECT '001' empno,'201003' mon,100 amt FROM DUAL
      3                )
      4  ,emp2 AS   ( SELECT '001' empno,'201001' mon,100 amt FROM DUAL UNION ALL 
      5               SELECT '001' empno,'201002' mon,200 amt FROM DUAL UNION ALL
      6               SELECT '001' empno,'201003' mon,100 amt FROM DUAL
      7              )
      8   SELECT coalesce(e1.empno,e2.empno) empno,
      9          coalesce(e1.mon,e2.mon) mon,
    10          coalesce(e1.amt,e2.amt)amt
    11   FROM emp1 e1 FULL OUTER JOIN emp2 e2
    12   ON e1.empno =e2.empno
    13     AND   e1.mon=e2.mon
    14  ORDER BY 2   ;
    EMP MON           AMT
    001 201001        100
    001 201002        200
    001 201003        100

  • How do make this query ?

    CREATE TABLE CLIENT (
         CLIENTID NUMBER PRIMARY KEY,
         NAME VARCHAR2(40)
    CREATE TABLE SALESMAN (
         SALESMANID NUMBER PRIMARY KEY,
         NAME VARCHAR2(40),
         ALL_CLIENTS NUMBER -- ACCESS ALL CLIENTS IF VALUE IS 1
    CREATE TABLE CLIENTSALESMAN (
         SALESMANID NUMBER,
         CLIENTID NUMBER
    INSERT INTO CLIENT VALUES(1,'Bob');
    INSERT INTO CLIENT VALUES(2,'Jhon');
    INSERT INTO CLIENT VALUES(3,'Robert');
    INSERT INTO CLIENT VALUES(4,'Clarck');
    INSERT INTO SALESMAN VALUES (1,'Christina',0);
    INSERT INTO SALESMAN VALUES (2,'Doug',1); -- access all clients
    INSERT INTO CLIENTSALESMAN VALUES (1,1);
    INSERT INTO CLIENTSALESMAN VALUES (1,2);
    How do you return all the clients of a salesman ? same that SALESMAN.ALL = 1 OR SALESMAN.ALL = 0.
    the salesman.all is 1 then he access all clients no need insert in CLIENTSALESMAN. If SALESMAN.ALL = 0 he
    access clientsalesman.
    Does somebody some suggestion how i make this ?
    thanks !

      1  select *
      2  from (select a.name SALESMAN, b.name CLIENT
      3  from   salesman a, client b, clientsalesman
      4  where  a.SALESMANID = c.SALESMANID
      5  and    b.CLIENTID = c.CLIENTID
      6  union
      7  select a.name SALESMAN, b.name CLIENT
      8  from   salesman a, client b
      9  where   a.ALL_CLIENTS = 1)
    10* where salesman = '&1'
    SQL> /
    Enter value for 1: Christina
    old  10: where salesman = '&1'
    new  10: where salesman = 'Christina'
    Christina                                Bob
    Christina                                Jhon
    SQL> /
    Enter value for 1: Doug
    old  10: where salesman = '&1'
    new  10: where salesman = 'Doug'
    Doug                                     Bob
    Doug                                     Clarck
    Doug                                     Jhon
    Doug                                     RobertNicolas.

  • XPath query against XMLType

    Hello,
    I am trying to reproduce the following XPath query using XDB functionality against a XMLType column:
    //AtomicPart[@MyID='190' or @MyID='495' or @MyID='1662']
    If I do the following I do get all AtomicParts:
    select X.xml.extract('//AtomicPart') FROM TEST X
    But I havent figured out how to do the or operation. Is it possible or does it require views?
    Thank you,
    Robert

    Robert
    Need to see the instance document in order to answer this..

  • How to make SAP Query additional field as one of the selection field ?

    Hi experts,
    I'm working on a AdHoc query. I added some Additional fields to the infoset. I put Abap code to populate this additional fields as output fields but I want to make these fields as selection fields also.
    How can I accomplish this ?
    I'd appreciate any answer or suggestion.
    Thanks in advance.

    See Extended / Quick Search capability with attributes in the following SAP notes.
    [482338 - Using Extended Search in ISA B2B, ver. 30|https://service.sap.com/sap/support/notes/482338]
    [792556 - Quick search using several attributes|https://service.sap.com/sap/support/notes/792556]
    [888528 - ISA R/3 4.0: Extended catalog search not consistent|https://service.sap.com/sap/support/notes/888258]

  • How to make this query go faster

    Hi ,
    I have the following query :
    select a.* from
    tbl1 a , tbl2 b
    where a.id = b.id
    substr(b.id , 3, 2) <> 'XX'
    and b.date1 is not null
    and b.date1 >= sysdate - 90 ;
    tbl1 - 21 million rows
    tbl2 - 2 millions
    i specify this hints /*+ INDEX(idxa_1 , idxa_2) INDEX(ixdb_1)
    where idxa_1 --> b.lotid
    idxa_2 --> b.date1
    idxb_1 --> a.lotid
    IF i DO NOT include b.date1 is not null and b.date1 >= sysdate - 90 ,
    from explain plan i could see it using a FAST FULL SCAN which really returns very fast
    HOWEVER if i include b.date1 is not null and b.date1 >= sysdate - 90
    , from explain plain it uses row index and then there's a range scan and its slow
    how can i improve the performance of this query ?
    pls advise
    tks & rdgs

    Don't create the temporary table.
    Create a function based index on table two
    substr(id , 3, 2)Make sure you have gathered statistics on the tables.
    Remove the hint.
    select a.* from
    tbl1 a , tbl2 b
    where a.id = b.id
    and substr(b.id , 3, 2) <> 'XX'
    and b.date1 >= sysdate - 90;If you still have performance problems, post the formatted explain plan from sqlplus.
    Read the Performance Tuning Guide.
    Unfortunately this is not urs advice.

Maybe you are looking for

  • No data in the ap_selected_invoice_checks_all table

    Hi Friends, I am using a table called ap_selected_invoice_checks_all in a custom report. But in R12 there is no data in that table. But But in oracle 11.5.8 data is there in that table. If not is there any other table in R12 instead of this table ap_

  • I can use the same account on two computers?

    I can use the same account on two computers?

  • ITunes stopped syncing Aperture photos to my ATV and iPad

    Out of the blue my iTunes has completely stopped syncing my Aperture photo library to both iPad and ATV devices. In iTunes the drop-down selection for iPhoto and Aperture is there but when I click sync nothing happens. My video, audio and apps all sy

  • Need some info about Stor.e TV

    Hi, I'm considering buy a Stor.e TV 2TB unit and wondered if anyone with one could answer a couple of questions that i can find covered in the marketing info? 1. Does the menu include grahics related to the files? if I rip and album(or DVD) to the de

  • How to track my App download?

    I've just purchased a game in the app store, but it's been a bit weird as I had to confirm some details, and now I can't actually work out whether the game is downloading or whatever. Can anyone advise me as to how I can see the progress of the downl