Display result of function XMLTABLE

Hi all

Can any please help me to reach the requirement below.

I need display output using function XMLTable, as shown below:

I have a Table like this,

CREATE TABLE BOMLIST (Cid INT PRIMARY KEY, ELEMENTS XMLTYPE);


I inserted the next record,

insert into BOMLIST (Cid, ELEMENTS) values (1, ')
< item desc = "computer" model = "L1234123" >
< part desc = "computer" partnum = "5423452345" >
< desc 'mother' = part partnum = "5423452345" >
< part desc = partnum "CPU" = "6109486697" >
< part desc = "registration" partnum = "6109486697" / >
< / part >
< part desc = "memory" partnum = "545454232" >
< part desc = "transistor" partnum = "6109486697" / >
< / part >
< / part >

< part desc = "hard disk" partnum = "6345634563456" >
< part desc = "spindlemotor" partnum = "191986123" / >
< / part >
< part desc = "powersupply" partnum = "098765343" >
< part desc = "powercord" partnum = "191986123" / >
< / part >
< / part >

< part desc = "monitor" partnum = "898234234" >
< part desc = "cathoderaytube" partnum = "191986123" / >
< / part >

< part desc = "keyboard" partnum = "191986123" >
< part desc = "keys" partnum = "191986123" / >
< / part >

< part desc = "mouse" partnum = "98798734" >
< part desc = "mouseball" partnum = "98798734" / >
< / part >
< / point >
')

I want to output,

ITEMNAME PARENT PART
-------------------- -------------------- --------------------
computer system computer computer system
computer motherboard computer system
computer CPU motherboard
computer registry CPU system
mother computer system memory card
transistor computer system memory
computer hard drive computer system
system computer spindlemotor hard drive
computer computer power supply system
computer system power power cable
computer monitor computer system system
system computer cathoderaytube monitor
system computer keyboard computer system
computer keyboard keys
computer system mouse computer system
computer system mouseball mouse


I used the query,

SELECT
A.ITEMNAME,
B.PART,
B.PARENT
OF BOMLIST.
XMLTABLE('$doc/item' passing BOMLIST.) ELEMENTS such as "doc".
COLUMNS
ITEMNAME varchar (20) PATH '. / @desc',
XML PATH ELEMENT '.'
) AS A,.
XMLTABLE ('$doc / / part ' in PASSING A.ITEM AS "doc")
COLUMNS
PATH varchar (20) PART '. / @desc',
PATH VARCHAR (20) PARENT '... @desc'
) AS B

Get output,

ITEMNAME PARENT PART
-------------------- -------------------- --------------------
computer system
computer system motherboard
computer system CPU
Computer registry
computer system memory
transistor computer system
computer hard drive system
system computer spindlemotor
system computer powersupply
power cable from the computer system
Monitor computer system
system computer cathoderaytube
computer keyboard
system computer keycaps
computer mouse
system computer mouseball

that is, Parents column'm NULL values.

Thank you
Sunil. N
SQL> SELECT cast(regexp_substr(column_value,'[^-]+',1,1) as varchar2(30)) col1,
  2    cast(regexp_substr(column_value,'[^-]+',1,2) as varchar2(30)) col2      ,
  3    cast(regexp_substr(column_value,'[^-]+',1,3) as varchar2(30)) col3
  4     FROM bomlist,
  5    xmltable( 'for $str in $doc/item/descendant::* return concat(data($doc/item/@desc),''-'',data
($str/@desc),''-'',data($str/../@desc))' passing bomlist.ITEMS AS "doc")
  6
SQL>
SQL> /

COL1                           COL2                           COL3
------------------------------ ------------------------------ ------------------------------
computersystem                 computer                       computersystem
computersystem                 motherboard                    computer
computersystem                 CPU                            motherboard
computersystem                 register                       CPU
computersystem                 memory                         motherboard
computersystem                 transistor                     memory
computersystem                 diskdrive                      computer
computersystem                 spindlemotor                   diskdrive
computersystem                 powersupply                    computer
computersystem                 powercord                      powersupply
computersystem                 monitor                        computersystem

COL1                           COL2                           COL3
------------------------------ ------------------------------ ------------------------------
computersystem                 cathoderaytube                 monitor
computersystem                 keyboard                       computersystem
computersystem                 keycaps                        keyboard
computersystem                 mouse                          computersystem
computersystem                 mouseball                      mouse

16 rows selected.

SQL> 

The same query, it works for me...
In xquery... it won't copy the piece in a loop, it will just point it to the same xml file, but for a node to define... And you can cross anyside you like later...

SQL> select * from v$version;

BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
PL/SQL Release 10.2.0.4.0 - Production
CORE    10.2.0.4.0      Production
TNS for HPUX: Version 10.2.0.4.0 - Production
NLSRTL Version 10.2.0.4.0 - Production

Ravi Kumar

Tags: Database

Similar Questions

  • Are the XQuery functions that are supported in the path of a function XMLTable clause?

    Hello

    Oracle 11.2, can I use XQuery functions in the path of a function XMLTable clause? I tried, but does not fit any result. Here is an example with and without the function fn:lower-case():

    SQL >
    SELECT EVENT_ID, ACTION
    OF EVENTSCHEMA.event x,.
    XMLTABLE ('/ *' from EVENTXMLTEXT)
    COLUMNS
    PATH varchar (10) ACTION ' / * / action'
    );

    EVENT_ID ACTION
    ------------- -----------
    1000 OBSERVE
    1001 OBSERVE

    SQL >
    SELECT EVENT_ID, ACTION
    OF EVENTSCHEMA.event x,.
    XMLTABLE ('/ *' from EVENTXMLTEXT)
    COLUMNS
    ACTION varchar (10) PATH "fn:lower - case(/*/action)".
    );

    EVENT_ID ACTION
    ------------- -----------
    1000
    1001


    At the end of the day, I will generate lines such as

    PATH of char (1) INFERRED ' if (fn:upper - case(/*/cah:extension/cah:inferred) = 'TRUE') then if "t" ElseIf (fn:upper - case(/*/cah:extension/cah:inferred) = 'FALSE') then 'f' not null'.
    PATH of TIMESTAMP BIZTRANSACTIONDATE "fn:adjust - dateTime-to-timezone(/*/cah:extension/cah:bizTransactionDate).

    but they also return null. If I remove the XQuery functions in them, they work.

    Do you know what could be the problem here?

    Thank you!
    -Daniela

    Works for me:

    SQL> with my_sample_table as (
      2    select xmltype('
      3    MONDAY
      4    TUESDAY
      5    WEDNESDAY
      6    TUESDAY
      7    FRIDAY
      8    SATURDAY
      9    SUNDAY
     10  ') xmldoc
     11    from dual
     12  )
     13  select x.*
     14  from my_sample_table t
     15     , xmltable(
     16        '$d/days/day'
     17        passing t.xmldoc as "d"
     18        columns day varchar2(30) path 'if (string-length(.)>6) then lower-case(.) else (.)'
     19       ) x
     20  ;
    
    DAY
    ------------------------------
    MONDAY
    tuesday
    wednesday
    tuesday
    FRIDAY
    saturday
    SUNDAY
    
    7 rows selected
     
    

    Do you know what could be the problem here?

    Please post an example of XML document.

  • Unable to get XML attributes in elements with function XMLTABLE

    I cannot get attributes of an XML stored in an XMLTYPE column.  The XML uses primarily attributes rather than items with a value of tag/matching.  If I put the knot in the first argument of the function XMLTABLE, he shoots the attribute at this level.  However, when I try to retrieve the attributes of the child node, I don't get the attribute values.  I'm working on the 11.2.0.3.0 Oracle database version.

    This is the create/insert statements:

    CREATE TABLE XML_TBL_TEST

    (

    ID NUMBER,

    XMLTYPE data

    );

    INSERT INTO XML_TBL_TEST

    VALUES (1, xmltype ("< user >

    < username = "Name1" >

    <>projects

    < Project = '100' QId OpId = PName "101" = "PName1" >

    < group >

    < group GName = "GName1" >

    elements <>

    < point OName = "OName1" Type = "Type1" >

    < ops >

    < op PType = material 'PType1' = 'Mat1"series = PStyle"Series1"="PStyle1">

    < options >

    < name of option = "Name1" Value = "V1" / >

    < name of option = "Name2" Value = "V2" / >

    < name of option = "Name3" Value = "V3" / >

    < / options >

    < /op >

    < op PType = material 'PType2' = 'Mat2"series = PStyle"Series2"="PStyle2">

    < options >

    < option Name = "Conjoint4" Value = "V4" / >

    < name of option = "Name5" Value = "V5" / >

    < option Name = "Name6" Value = "V6" / >

    < / options >

    < /op >

    < / ops >

    < / point >

    < point OName = "OName2" Type = "Type2" >

    < / point >

    < / object >

    < / Group >

    < group GName = "GName2" >

    < point OName = "OName3" Type = "Type3" >

    < / point >

    < / Group >

    < / group >

    < / project >

    < OpId project = "200" QId = "201" PName = "PName2" >

    < / project >

    < / project >

    < / user >

    < username = "Name2" >

    < / user >

    < username = "Name3" >

    < / user >

    ((< / user > '));

    The query below will draw the Name attribute in the element of the user but not the OpId, QId and PName attributes on the child of the Project element.

    SELECT x.*

    OF XML_TBL_TEST t.

    XMLTABLE (-with xmlnamespaces ('http://www.w3.org/2001/XMLSchema-instance' as "xsi"), )

    "/ Users/user.

    PASSAGE t.data

    COLUMNS - ID FOR ORDINALITE 'ID,' NUMBER

    Name VARCHAR2 (30) PATH "@Name."

    PATH of VARCHAR2 (30) PName ' / Projects/Project/@PName',

    QId NUMBER PATH ' / Users/User/Projects/Project/@QId' by DEFAULT 0,

    OpId NUMBER PATH '. (/ Project/@OpId' 0 by DEFAULT) x;

    The following query will get OpId, QId and PName attributes in the child project item.

    SELECT x.*

    OF XML_TBL_TEST t.

    XMLTABLE (-with xmlnamespaces ('http://www.w3.org/2001/XMLSchema-instance' as "xsi"), )

    "/ Users/user/projects/Project.

    PASSAGE t.data

    COLUMNS - UserName VARCHAR2 (30) PATH "@Name."

    PName VARCHAR2 (30) PATH "@PName."

    QId NUMBER PATH "@QId" default 0,

    OpId NUMBER PATH "@OpId" DEFAULT 0) x;

    How can I get all the attributes for a given element in the XML document.  I tried a number of options without success.

    FYI, SM

    Because there may be several projects under a user, you must use a 2nd XMLTABLE chained (or a more complex XQuery expression) to retrieve the attributes of two orders:

    SQL > SELECT / * + no_merge (x 1) * /.

    2 x 1. Username, x2.*

    Xml_tbl_test 3 t

    4, XMLTABLE)

    5 "/ users/user.

    6 in PASSING t.data

    7 COLUMNS

    Username 8 VARCHAR2 (30) PATH '@Name '.

    9, XMLType PATH "Projects/Project" projects

    (10) x 1

    11, XMLTABLE)

    12 "/ project".

    13 by the WAY x 1. Projects

    14 COLUMNS

    NUMBER 15 QId PATH '@QId '.

    16, ROAD NUMBER OpId '@OpId '.

    17, PName VARCHAR2 (30) PATH '@PName '.

    (18) (+) x 2

    19;

    QID OPID PNAME USERNAME

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

    Name1 PName1 101 100

    Name1 PName2 201 200

    NAME2

    NAME3

    NB: I used the trick no_merge because of a bug in my version (11.2.0.4)

  • Sensitive colouring text "display results that include all search words.

    I use RoboHelp 2015 Version 12.02.384.

    I created a provision of the screen responsive HTML5 Adobe provided Charcoal Grey -based layout and adjust the colors to match the image of my company.

    The "use search option"is enabled and displays the text"show results that include all search words" on the tab "" Search " and the function bar." But the text is displayed in gray on the "Search" tab and is virtually unreadable.

    How can I change the color of the "'show results that include all search words" string on the tab "Search"? "

    Change the color of messages did not work so I've edited layout.css and changed the value of the color in the next section. That fixed it. Thanks for your help.

    {label.wSearchAndLabelResults Body.Media - Office div.searchresults.search - sidebar}

    Display: block;

    margin-bottom: .75em;

    padding-top: .75em;

    padding-bottom: .75em;

    padding-left: 1.75em;

    Color: #000000;

    }

  • How to display records by several XMLTABLE() NULL

    First of all, let me provide the test SQL INSERT and CREATE TABLE data:
    create table xml_t2 (xml_raw XMLTYPE);
    Insert sql, a little long... just copy and paste, then run it will be OK!
    the system warns: your message exceeds the maximum length of 30000 characters.
    So, I place it on the space of shariing mediafire
    http://www.mediafire.com/?npmot6lgl86dgli
    Tests of SQL:
    SELECT t1.years, t1.months,t1.days,t1.hours,t1.value,t2.value
                    
            FROM xml_t2,
            XMLTABLE ('$d/cdata/F1' passing xml_raw as "d" COLUMNS years integer path '//year', months varchar(3) path '//month', days varchar(2) path '//day', hours varchar(2) path '//hour', mins varchar(2) path '//minute', value float path '//value') t1 ,
            XMLTABLE ('$d/cdata/F2' passing xml_raw as "d" COLUMNS years integer path '//year', months varchar(3) path '//month', days varchar(2) path '//day', hours varchar(2) path '//hour', mins varchar(2) path '//minute', value float path '//value') t2
    The condition at the moment is... In the xml data, I deleted the month "Jan" with the < F2 > tag that is in 2010.
    This means that the XMLTABLE t2 output will not contain records of "Jan", but it is still in XMLTABLE t1.

    The problem is that when I use the SQL above to display the t1.value, that it will not display the t1.value in Jan 2010... it just jump "Jan" and becomes "February"...
    to view what I prefer, it is something like this:
    YEARS MONTHS DAYS HOURS t1_value t2_value
    ----- ------ ---- ----- -------- --------
    2009     Jan    01   01       8       8
    2009     Jan    01   02       8     580
    2009     Jan    02   01     580     580
    2009     Jan    02   02     580     580
    2009     Feb    01   01     440     440
    .....................
    .....................
    2010     Jan    01   01     627     NULL
    2010     Jan    01   02     627     NULL
    2010     Jan    02   01     367     NULL
    2010     Jan    02   02     367     NULL
    2010     Feb    01   01     367     849
    2010     Feb    01   02     849     849
    ....................
    ..............
    Then... the main problem is how transparent back in January 2010 in t1 XMLTABLE record and assign null to the XMLTABLE t2 since it doen't contains this month record.

    THANKS for the help!

    The following code generates the desired result on the 11.2.0.2 version, and it indexes the beaches of analyses on the index.

    SELECT t1.years, t1.months,t1.days,t1.hours,t1.value,t1.value2
    FROM xml_t2,
    XMLTABLE ('$d/cdata' PASSING XML_RAW AS "d" COLUMNS
    YEARS INTEGER PATH 'F1/name/year',
    MONTHS VARCHAR(3) PATH 'F1/name/month',
    DAYS VARCHAR(2) PATH 'F1/name/day',
    HOURS VARCHAR(2) PATH 'F1/name/hour',
    MINS VARCHAR(2) PATH 'F1/name/minute',
    VALUE FLOAT PATH 'F1/name/value',
    VALUE2 FLOAT PATH 'F2/name/value') T1;
    

    If you think that my answers are "useful" or "correct" Please mark as well.

    A XMLTABLE expected to perform generally better than two.

  • Satellite Pro L850 - Driver/tool for the display of the functions of the F keys

    Hello

    I have a L850 Pro of the Satellite with "nine" Windows 7 Home Premium. I had to reinstall windows and I do not have the recovery DVD, so I used a Windows DVD installation and installed the drivers manually.

    The only thing I miss now is the display of the F1 to F12 key functions (like brighter, stronger, touchpad switch, Wifi/Bluetooth power and so on).

    Can you tell me, what driver Toshiba or tool do I need?

    Thank you very much.

    Andy

    Hi Andy

    What you need is the package of added value. This package contains several tools and utilities. One of them is utility of Flash cards. This tool is for Flash cards that you see at the top of the screen when you press the FN key.

  • How can I display results horizontally

    Hi-

    ColdFusion Report Builder by default displays the outcome vertically, for example, something like this:

    Number
    Zone_ID Zone_Nameof Emplyees
    1A47
    2B65
    3C100
    4D32

    But I want to disply results horizontally

    Areas A B C D
    Number of employees476510032

    Any ideas how to do?

    Thank you

    Design your database query to return the result in the format that you describe. This will make your report of very simple design.

    To create the desired result set that you gave in your post, looking for the term "pivot" or "cross tab" to know how to do it using your database of choice engine.

  • SQL MORE: printscreen off or disable display result

    Hi all

    I am using sqlplus that accompanies the new oracle 11g release 1... Anyone know how I can disable myscreen to display the result of a query?
    I do not want to write in a file-just do not print output to the screen... I run a query where all I need is just the time spent and not the result because I join millions of records.

    Thank you and happy holidays
    SQL> SET AUTOTRACE TRACEONLY
    
    SQL> SET TIMING ON
    
    SQL> SELECT * FROM dba_objects;
    
    9656 rows selected.
    
    Elapsed: 00:00:00.13
    
    Execution Plan
    ----------------------------------------------------------
    Plan hash value: 2127761497
    
    ----------------------------------------------------------------------------------------------
    | Id  | Operation                 | Name          | Rows  | Bytes | Cost (%CPU)| Time     |
    ----------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT            |          |     8764 |     1514K|       39   (3)| 00:00:01 |
    |   1 |  VIEW                      | DBA_OBJECTS |     8764 |     1514K|       39   (3)| 00:00:01 |
    |   2 |   UNION-ALL                 |          |          |          |            |          |
    |*  3 |    FILTER                 |          |          |          |            |          |
    |*  4 |     HASH JOIN                 |          |     9815 |      872K|       37   (3)| 00:00:01 |
    |   5 |      TABLE ACCESS FULL            | USER$          |       27 |      459 |        2   (0)| 00:00:01 |
    |*  6 |      TABLE ACCESS FULL            | OBJ$          |     9815 |      709K|       34   (0)| 00:00:01 |
    |*  7 |     TABLE ACCESS BY INDEX ROWID| IND$          |        1 |        7 |        2   (0)| 00:00:01 |
    |*  8 |      INDEX UNIQUE SCAN            | I_IND1      |        1 |          |        1   (0)| 00:00:01 |
    |   9 |    TABLE ACCESS BY INDEX ROWID | LINK$          |        1 |       88 |        0   (0)| 00:00:01 |
    |  10 |     NESTED LOOPS            |          |        1 |      105 |        2   (0)| 00:00:01 |
    |  11 |      TABLE ACCESS FULL            | USER$          |       27 |      459 |        2   (0)| 00:00:01 |
    |* 12 |      INDEX RANGE SCAN            | I_LINK1     |        1 |          |        0   (0)| 00:00:01 |
    ----------------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       3 - filter("O"."TYPE#"<>1 AND "O"."TYPE#"<>10 OR "O"."TYPE#"=1 AND  (SELECT 1 FROM
               "SYS"."IND$" "I" WHERE "I"."OBJ#"=:B1 AND ("I"."TYPE#"=1 OR "I"."TYPE#"=2 OR
               "I"."TYPE#"=3 OR "I"."TYPE#"=4 OR "I"."TYPE#"=6 OR "I"."TYPE#"=7 OR "I"."TYPE#"=9))=1)
       4 - access("O"."OWNER#"="U"."USER#")
       6 - filter("O"."NAME"<>'_NEXT_OBJECT' AND "O"."NAME"<>'_default_auditing_options_'
               AND "O"."LINKNAME" IS NULL)
       7 - filter("I"."TYPE#"=1 OR "I"."TYPE#"=2 OR "I"."TYPE#"=3 OR "I"."TYPE#"=4 OR
               "I"."TYPE#"=6 OR "I"."TYPE#"=7 OR "I"."TYPE#"=9)
       8 - access("I"."OBJ#"=:B1)
      12 - access("L"."OWNER#"="U"."USER#")
    
    Statistics
    ----------------------------------------------------------
           0  recursive calls
           0  db block gets
           2978  consistent gets
           0  physical reads
           0  redo size
         538818  bytes sent via SQL*Net to client
           7541  bytes received via SQL*Net from client
         645  SQL*Net roundtrips to/from client
           0  sorts (memory)
           0  sorts (disk)
           9656  rows processed
    
  • Installed updates are not displayed in the functions of the program

    I apply MS Updates regularly and don't have some exceptional outside two optional updates that do not install updates. However, when I Visit > program features > view installed updates no updates installed are displayed many updates are missing, including any for Vista. The freeware Software Inspector for Windows product displays updates as it is correctly installed! I ran the difficulty it utility provided by Microsoft with no joy. Any ideas?

    Dell Inspiron 530; Vista Home Premium SP2

    I think that a clean install would be better here, too. I assumed that the data on the D: drive would be preserved, Yes, but better check with Dell Support for more guidance.

    Personal data backup (which none should be considered 100% reliable at this point) then format the HARD disk and do a clean install of Windows.  Please note that a repair installation (upgrade AKA on-site) won't fix this!

    HOW to do a clean install of Vista: section "If you want to reinstall Windows Vista by running a new installation...". " http://windows.microsoft.com/en-us/windows-vista/Installing-and-reinstalling-Windows-Vista (or contact Dell technical support)

    Once installed the clean, you will have the equivalent of a "new computer" in order to take care of everything on the next page before connecting the machine to the internet or one local network (i.e. other computers) otherwise and before using a flash drive or the SD card that is not brand new, or has not been freshly formatted:

    4 steps to help protect your new computer before going online
         http://www.Microsoft.com/security/pypc.aspx

    Tip: After getting the computer fully patched, download/install KB971029 manually: http://support.microsoft.com/kb/971029

    NB: The McAfee free trial which is preinstalled on the computer when you bought will be reinstalled (but invalid) when Windows is reinstalled. You MUST uninstall the trial for free and download/run the removal tool products McAfee Consumer before you install updates, Windows Service Packs or IE upgrades and before installing your new antivirus application (for example, Microsoft Security Essentials; free).

    If these procedures look too complex - and there is no shame in admitting this isn't your cup of tea - take the machine to a local, good reputation and stand-alone computer (that is, not BigBoxStoreUSA or Geek Squad) repair facility.

    ~ Robear Dyer (PA Bear) ~ MS MVP (that is to say, mail, security, Windows & Update Services) since 2002 ~ WARNING: MS MVPs represent or work for Microsoft

  • How can I add a filter on my Web site, which displays results immediately on the same page?

    Hoe kan ik een filter toevoegen op mijn site, results old weer geeft die in of zelfde pagina?

    This is not possible with Muse

  • Display results selected from a range.

    Hi, I have a Web page where I try to display the name of the people who are in a certain age range. The I'm putting in place is to have a group of links, for example,.
    18-25
    26-35
    36-45
    and when one of these age group is chosen to display the name of the people in my database that fall into this age group. I need to know how to know coldfusion to select only the names where ages are in the selected range.

    appropriately:
    Add an array of strings to your db and a crosstab to connect people with a particular range. then your list of beaches will have corresponding rangeid of the table of beaches, you will pass on and make selection of names to display based on the same id assigned to a name in the PivotTable range.

    incorrectly:
    treat the value of the selected as a list with a "-" as a separator. then you have age min and Max select names which has age is gte min and max of lte. you need 2 params to your query/next page: minimum age and maximum age.

  • XMLTable returns no results if you use an optional element in line-generations. exp

    Hello

    I need assistance with a view that returns no data. Point of view joined relational columns from two tables with the binary XML column values. The problem is that if the XML element in the expression of generators on the line of the function XMLTable does not exist, the view returns 0 rows, despite the use of a left outer join.
    SQL> select * from V$Version;
    
    BANNER
    --------------------------------------------------------------------------------
    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    PL/SQL Release 11.2.0.3.0 - Production
    CORE    11.2.0.3.0      Production
    TNS for Linux: Version 11.2.0.3.0 - Production
    NLSRTL Version 11.2.0.3.0 - Production
    It is an example of a document:
    <ObjectEvent>
       <eventTime>2009-03-10T01:02:00.827-06:00</eventTime>
       <eventTimeZoneOffset>-06:00</eventTimeZoneOffset>
       <epcList>
          <epc>urn:epc:id:sgtin:030093.0098109.100000000001</epc>
          <epc>urn:epc:id:sgtin:030093.0098109.100000000002</epc>
          <epc>urn:epc:id:sgtin:030093.0098109.100000000003</epc>
       </epcList>
       <bizStep>urn:epcglobal:bizstep:commissioning</bizStep>
       <mycorp:quantity xmlns:mycorp="http://www.mycorp.com" epc="urn:epc:id:sgtin:030093.0098109.100000000001">10</mycorp:quantity>
       <mycorp:quantity xmlns:mycorp="http://www.mycorp.com" epc="urn:epc:id:sgtin:030093.0098109.100000000002">20</mycorp:quantity>
       <mycorp:quantity xmlns:mycorp="http://www.mycorp.com" epc="urn:epc:id:sgtin:030093.0098109.100000000003">30</mycorp:quantity>
    </ObjectEvent>
    The display should return a line by EPC and the corresponding mycorp:quantity of the list. If the mycorp:quantity of the element does not exist, I still want three rows back, one for each EPC, but with empty columns of quantity.

    It's point of view:
    SELECT e.event_id, e.epc, UNIT_QUANTITY, UNIT_QUANTITY_EPC
    FROM EVENTSCHEMA.event z , 
             EVENTSCHEMA.epc e LEFT OUTER JOIN 
             XMLTABLE (XMLNAMESPACES ('http://www.mycorp.com' AS "mycorp"), '$e/*/mycorp:quantity' passing z.EVENTXMLTEXT as "e"
                 COLUMNS 
                      UNIT_QUANTITY        NUMBER(10)        PATH  '.',  
                      UNIT_QUANTITY_EPC   VARCHAR  (2000)  PATH  '@epc'
     ) t1 ON t1.UNIT_QUANTITY_EPC = e.epc 
    WHERE e.event_id = z.event_id;
    The result looks OK if the < mycorp:quantity > element exists in the document:
      EVENT_ID      EPC                                              UNIT_QUANTITY       UNIT_QUANTITY_EPC
    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
          1020      urn:epc:id:sgtin:030093.0098109.100000000003         30            urn:epc:id:sgtin:030093.0098109.100000000003
    
          1020      urn:epc:id:sgtin:030093.0098109.100000000001         10            urn:epc:id:sgtin:030093.0098109.100000000001
    
          1020      urn:epc:id:sgtin:030093.0098109.100000000002         20            urn:epc:id:sgtin:030093.0098109.100000000002
    However, if this element does not exist in the document, the view returns an empty result set. It seems that the left outer join is thrown because the path of generating line expression expression ("$e / * / mycorp:quantity" "") does not actually exist in the document. My application needs to support Oracle and DB2. On DB2 that this point of view works as expected, so the syntax seems to be OK.

    My next attempt was to add a case distinction to the term generating line, as described in this article from devWorks . The article recommends to add a set of two expressions, which is always empty. In my example, the bizStep item is returned if there is no such thing as the mycorp:quantity element:
    SELECT e.event_id, e.epc, UNIT_QUANTITY, UNIT_QUANTITY_EPC
    FROM EVENTSCHEMA.event z , 
             EVENTSCHEMA.epc e LEFT OUTER JOIN 
             XMLTABLE (XMLNAMESPACES ('http://www.mycorp.com/pedigree' AS "mycorp"), '$e/*/(mycorp:quantity,.[fn:not(mycorp:quantity)]/bizStep)' passing EVENTXMLTEXT as "e"
                 COLUMNS 
                      UNIT_QUANTITY       NUMBER(10)      PATH  '.[../mycorp:quantity]',  
                      UNIT_QUANTITY_EPC  VARCHAR(2000)  PATH  '.[../mycorp:quantity/@epc]'
     ) t1 ON t1.UNIT_QUANTITY_EPC = e.epc 
    WHERE  e.event_id = z.event_id;
    This works well if the mycorp:quantity element does not exist:
      EVENT_ID      EPC                                                                      UNIT_QUANTITY       UNIT_QUANTITY_EPC
    ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
          1020          urn:epc:id:sgtin:030093.0098109.100000000001        
    
          1020          urn:epc:id:sgtin:030093.0098109.100000000002       
    
          1020          urn:epc:id:sgtin:030093.0098109.100000000003     
    but does not return any rows if the mycorp:quantity exists!

    Can someone help me? Is an expression of step parent in the COLUMN of output expression supported in Oracle? I also tried
    UNIT_QUANTITY       NUMBER(10)  PATH  '../mycorp:quantity'
    but who would return ORA-19110: unsupported XQuery expression.

    Thank you!
    Daniela

    Published by: dwersin on July 19, 2012 14:28
  • Why my XMLTable function does not work?

    Hello

    I'm reading my XML document using a function XMLTable, because a repetition of elements may occur. I wrote a SQL script to test this feature, but it does give me the desired output. This is my script. I use a shadow table PETER_XML to pass the value to the function XMLTable. I would have rather done it directly with a PL/SQL variable, but it does not work.

    CREATE TABLE PETER_XML (AVY XMLTYPE);

    Set serveroutput size 100000
    set echo on
    Set of feedback on

    declare

    cursor c_avy is
    SELECT XMLRESPONSE. DepartureStation' DEPARTURE,
    XMLRESPONSE. "" Flight "FLIGHTNR
    OF PETER_XML.
    XMLTABLE (XMLNameSpaces ('http://schemas.navitaire.com/WebServices' as "web", ))
                                  ' http://schemas.xmlsoap.org/SOAP/envelope/ "as"soapenv", "
                                  ' http://schemas.Navitaire.com/webservices/servicecontracts/BookingService ' as 'book',
                                  ' http://schemas.Navitaire.com/webservices/DataContracts/booking ' as "Book1",
                                  ' http://schemas.Microsoft.com/2003/10/Serialization/Arrays ' as "arr",
                                  ' http://schemas.Navitaire.com/webservices/DataContracts/common/enumerations ' as 'enum',
                                  ' http://schemas.Navitaire.com/webservices/servicecontracts/BookingService ' as 'ns0',
                                  ' ( http://schemas.Navitaire.com/webservices/DataContracts/Booking ' as 'ns1'),
    ' / / GetAvailabilityRequest/TripAvailabilityRequest/AvailabilityRequests/AvailabilityRequest.
    PETER_XML OF PASSAGE. AVY
    COLUMNS
    "DepartureStation' VARCHAR2 (3) path"DepartureStation. "
    'Flight' varchar2 (4) WAY 'flight '.
    ) XMLRESPONSE.

    "" "clob l_response: = ' < soapenv:Envelope xmlns:soapenv ="http://schemas.xmlsoap.org/soap/envelope/"xmlns:web ="http://schemas.navitaire.com/WebServices"xmlns:book ="http://schemas.navitaire.com/WebServices/ServiceContracts/BookingService"xmlns:book1 ="http://schemas.navitaire.com/WebServices/DataContracts/Booking"xmlns:arr ="http://schemas.microsoft.com/2003/10/Serialization/Arrays"xmlns:enum ="http://schemas.navitaire.com/WebServices/DataContracts/Common/Enumerations">" "
    < soapenv:Header >
    bnuOiHCVb3k < web: Signature > = | GX + eTRcZ5ABozAy8MosBFwagyUw7zrRXf1iprmw9Q4W17wt8SDpjYV2HwZRGIHYtE46UFBJw/aFyKVqjToEAfSTfh7cePm4r9JJwcIveDc75NuxnzoY14pKC + WLYDzE0MaALra4i/tI = < / web: Signature >
    < web: ContractVersion > 340 < / web: ContractVersion >
    < / soapenv:Header >
    < soapenv:Body >
    < ns0:GetAvailabilityRequest xmlns:ns0 = "http://schemas.navitaire.com/WebServices/ServiceContracts/BookingService" > ""
    < ns1:TripAvailabilityRequest xmlns:ns1 = "http://schemas.navitaire.com/WebServices/DataContracts/Booking" > ""
    < ns1:AvailabilityRequests >
    < ns1:AvailabilityRequest >
    < ns1:DepartureStation > AMS < / ns1:DepartureStation >
    < ns1:ArrivalStation > CTA < / ns1:ArrivalStation >
    < ns1:BeginDate > 2013-07-13 T 00: 00:00 < / ns1:BeginDate >
    < ns1:EndDate > 2013-07-13 T 00: 00:00 < / ns1:EndDate >
    < ns1:CarrierCode > HV < / ns1:CarrierCode >
    < ns1:FlightNumber > 547 < / ns1:FlightNumber >
    < ns1:FlightType > all < / ns1:FlightType >
    < ns1:PaxCount > 1 < / ns1:PaxCount >
    < ns1:Dow > by day < / ns1:Dow >
    < ns1:CurrencyCode > EUR < / ns1:CurrencyCode >
    < ns1:DisplayCurrencyCode > EUR < / ns1:DisplayCurrencyCode >
    <!-ns1:SourceOrganization > COO < / ns1:SourceOrganization->
    < ns1:MaximumConnectingFlights > 0 < / ns1:MaximumConnectingFlights >
    < ns1:AvailabilityFilter > by default < / ns1:AvailabilityFilter >
    < ns1:ProductClassCode > NG < / ns1:ProductClassCode >
    < ns1:SSRCollectionsMode > None < / ns1:SSRCollectionsMode >
    < ns1:InboundOutbound > so < / ns1:InboundOutbound >
    < ns1:NightsStay > 0 < / ns1:NightsStay >
    < ns1:IncludeAllotments > true < / ns1:IncludeAllotments >
    < ns1:FareTypes >
    < ns2:string xmlns:ns2 = "http://schemas.microsoft.com/2003/10/Serialization/Arrays" > T < / ns2:string>
    < / ns1:FareTypes >
    < ns1:PaxPriceTypes >
    < ns1:PaxPriceType >
    < ns1:PaxType > ADT < / ns1:PaxType >
    < / ns1:PaxPriceType >
    < / ns1:PaxPriceTypes >
    < ns1:JourneySortKeys >
    < ns2:JourneySortKey xmlns:ns2 = "http://schemas.navitaire.com/WebServices/DataContracts/Common/Enumerations" > EarliestDeparture < / ns2:JourneySortKey>
    < / ns1:JourneySortKeys >
    < ns1:IncludeTaxesAndFees > false < / ns1:IncludeTaxesAndFees >
    < ns1:FareRuleFilter > by default < / ns1:FareRuleFilter >
    < ns1:LoyaltyFilter > MonetaryOnly < / ns1:LoyaltyFilter >
    < ns1:TravelClassCodeList >
    < ns2:string xmlns:ns2 = "http://schemas.microsoft.com/2003/10/Serialization/Arrays" > Y < / ns2:string>
    < / ns1:TravelClassCodeList >
    < / ns1:AvailabilityRequest >
    < / ns1:AvailabilityRequests >
    < ns1:LoyaltyFilter > MonetaryOnly < / ns1:LoyaltyFilter >
    < / ns1:TripAvailabilityRequest >
    < / ns0:GetAvailabilityRequest >
    < / soapenv:Body >
    < / soapenv:Envelope > ';

    Start

    dbms_output.put_line ('Start');
    insert into peter_xml (avy) values (XMLTYPE (l_response));


    dbms_output.put_line ('Insert processed' | to_char (sql % rowcount) |) "lines.") ;

    for r_avy loop c_avy

    dbms_output.put_line ('Start' | r_avy.departure |) "Flightno. ' | r_avy.flightnr);

    end loop;

    end;
    /

    Rollback;

    The script works well, but the problem is that I don't get any kind of output the cursor of the loop for. When I speak to elements using "ns1:etc", I get an error, which suggests that the service is actually read the XML. Since there was no way out, I started to including all these XMLNameSpaces.

    Can someone let me know what Miss me?

    And if I can pass the value to a PL/SQL variable, it would save me the use of a fictitious table. That would be nice.

    Thanks in advance.

    Peter

    Hi Peter,.

    Since there was no way out, I started to including all these XMLNameSpaces.

    All these namespaces have a meaning, do not blindly, include them but if you do, use.

    The main manifestation of XQuery does not reference all the necessary namespaces.

    Here is a simplified version that gives the expected results.

    Please note that I only use namespaces I want to solve the XQuery:

    declare

    c_avy (p_xmlresponse in xmltype) cursor is

    Select x.DEPARTURE

    x.FLIGHTNR

    from xmltable)

    XmlNamespaces)

    "http://schemas.xmlsoap.org/soap/envelope/" as "SOAP."

    , 'http://schemas.navitaire.com/WebServices/ServiceContracts/BookingService' as 'ns0 '.

    , "http://schemas.navitaire.com/WebServices/DataContracts/Booking" as "ns1."

    )

    , ' /: soap envelope / soap: Body / ns0:GetAvailabilityRequest / ns1:TripAvailabilityRequest / ns1:AvailabilityRequests / ns1:AvailabilityRequest'

    passage p_xmlresponse

    columns

    Trajectory of DEPARTURE VARCHAR2 (3) 'ns1:DepartureStation '.

    , Path of varchar2 (4) FLIGHTNR 'ns1:FlightNumber '.

    ) x ;

    "" l_response clob: = "http://schemas.xmlsoap.org/soap/envelope/" xmlns:web ="http://schemas.navitaire.com/WebServices" xmlns:book = "http://schemas.navitaire.com/WebServices/ServiceContracts/BookingService" xmlns:book1 ="http://schemas.navitaire.com/WebServices/DataContracts/Booking" xmlns:arr = "http://schemas.microsoft.com/2003/10/Serialization/Arrays" xmlns:enum ="http://schemas.navitaire.com/WebServices/DataContracts/Common/Enumerations" > ""

    bnuOiHCVb3k = | GX + eTRcZ5ABozAy8MosBFwagyUw7zrRXf1iprmw9Q4W17wt8SDpjYV2HwZRGIHYtE46UFBJw/aFyKVqjToEAfSTfh7cePm4r9JJwcIveDc75NuxnzoY14pKC + WLYDzE0MaALra4i/tI =.

    340

    http://schemas.Navitaire.com/webservices/servicecontracts/BookingService">

    http://schemas.Navitaire.com/webservices/DataContracts/booking">

    AMS

    CTA

    2013-07-13 T 00: 00:00

    2013-07-13 T 00: 00:00

    HV

    547

    All the

    1

    Every day

    EUR

    EUR

    0

    By default

    NG

    None

    Both

    0

    true

    http://schemas.Microsoft.com/2003/10/Serialization/Arrays "> T"

    ADT

    http://schemas.Navitaire.com/webservices/DataContracts/common/enumerations "> EarliestDeparture"

    fake

    By default

    MonetaryOnly

    http://schemas.Microsoft.com/2003/10/Serialization/Arrays "> Y"

    MonetaryOnly

    ';

    Start

    for r_avy in c_avy (xmltype (l_response)) in a loop

    dbms_output.put_line ('Start' | r_avy.departure |) "Flightno. ' | r_avy.flightnr);

    end loop;

    end;

    /

    In fact, you don't need an intermediate table for this requirement. However, and according to your version of db, store the XML in a binary XMLType table can significantly improve performance.

    For makers in small, you probably won't see a difference between the two approaches, but just so you know in the case where you have to face in the future with big XMLs.

  • [JS] The event handler function is presented as the result in the ESTK

    I have a ScriptUI tree, with a onExpand event, like this:

    Window1.tvwTree.onExpand  = function (item){
        $.writeln(item.key + " is now expanded.");
    }

    Whenever the script is run, I get this in the console to ExtendScript Toolkit Javascript:

    Execution finished. Result: onExpand()
    

    First question is: why?

    Second question: what is the best and cleanest way to take care of the event onExpand? I failed to assign a function to the event of onExpand, in the same way as I do for functions without parameters.

    For simple events, without parameters, I did like this:

    Window1.....DropDownList2.onChange = cboNewLanguage_onChange;

    ... but the onExpand event has its parameter to "point" to take care of, and I can't seem to assign the function in a similar way. Please enlighten me.

    (It would be possible to use a prototype approach, events like this? Get a common function for all events of onExpand...?)

    Thank you

    Andreas

    Hi Andreas,

    First question: what is supposed to be item.key? Did extend you the ListItem properties?

    How assign you the function of onExpand seems correct to me. The following code should work:

    var myExpandHandler = function(/*ListItem*/ item)
    {
         // this => TreeView
         // item => expanded ListItem
         alert( item.text + ' is now expanded.' );
    };
    myTree.onExpand = myExpandHandler;
    

    Alternatively, you can create a generic handler in the prototype of TreeView :

    TreeView.prototype.onExpand = function(/*ListItem*/ item)
    {
         // this => TreeView
         // item => expanded ListItem
         alert( item.text + ' is now expanded.' );
    };
    

    Works for me in CS4 & CS5 +.

    Note: the onExpand function has no equivalent event listener, you cannot use the form: .addEventListener ('expand', myEventListener).

    I don't know why your script causes the ESTK console display "result: onExpand() '. Your code probably contains the corresponding $.writeln somewhere, isn't? In addition, consider that if your user interface code uses something like myListItem.expanded = true; then the onExpand handler is called before win.show (). This may explain the unexpected reactions in the console (?)

    @+

    Marc

  • Display of the results of calculation of data provided by the user in the dynamic text field

    Hi people,

    I am trampled on this one... Sorry...

    So, I'm working on a calculator, hitting a button, will display results based on the user data. I can get all the math to work OK, and he retraces perfectly.

    Now, the question becomes it to display on the fla itself.

    (The strange thing is, I had to keep all the data in the function. If I took it out, I would get all kinds of errors NaN and others. "But keep it within the service does the job very well.)

    What I'm missing here? I tried to do a total.set_Text = refundAmt; - but no luck. (The name of the instance to the box in the FLA file is 'total')

    Here is my code:

    ------

    trace_btn.addEventListener (MouseEvent.CLICK, showStuff);

    function showStuff (evtObj:MouseEvent): void {}

    var theSalary:Number = parseFloat (this ["inputSalary"] .text);

    var theDaysYouWorked:Number = parseFloat (this ["inputDaysYouWorked"] .text);

    var theEligibleDays:Number = parseFloat (this ["inputEligibleDays"] .text);

    var refundAmt:Number = theSalary * 0.005 / theDaysYouWorked * theEligibleDays;

    var lawyerFee20:Number = refundAmt * 0.80;

    var lawyerFee25:Number = refundAmt * 0.75;

    var lawyerFee30:Number = refundAmt * 0,70;

    var lawyerFee35:Number = refundAmt * 0.65;

    trace (refundAmt, "$" refundAmt.toFixed (2), "$" + lawyerFee20.toFixed (2), "$" + lawyerFee25.toFixed (2), "$" + lawyerFee30.toFixed (2), "$" + lawyerFee35.toFixed (2));

    }

    -------

    If I try to start another function, the results are not part of the scope, so I can't access it.

    Thoughts? Thanks in advance!

    N

    large.

    Please mark this thread as answered, if you can.

Maybe you are looking for