Help in xquery

Hi guys,
how to add years to a date in osb.
as my tranformation needs target node as cobination of year+date, i tried with xquery functions avaailable in osb, but didnt find any function which adds year to a date.
Thanks in advance.
regards,
shaik.
Edited by: shaik.apps on Feb 25, 2010 8:58 PM

I don't know of any such a function in OSB. If I needed that now, I would probably have to split date into its components, add to year (as a number) and then again compose new date from components. Maybe something like this:
xquery version "1.0" encoding "UTF-8";
declare namespace xf = "http://com.mycompany/xquery/add-year";
declare function xf:pad($input as xs:integer)
    as xs:string {
        if ($input < 10)
        then
            fn:concat('0', $input)
        else
            xs:string($input)
declare function xf:add-to-year($date as xs:date, $years as xs:integer)
    as xs:date {
     xs:date(fn:concat(fn:year-from-date($date)+$years, '-', xf:pad(fn:month-from-date($date)), '-', xf:pad(fn:day-from-date($date))))
xf:add-to-year(fn:current-date(), 3)What an ugly thing! :-) Hope somebody around knows something better ...

Similar Messages

  • [ALSB 3.0] help help about xquery transformation

    Hi all,
    I should transform a xml doc from
    <val_date>20081004</val_date>
    <par>
    <key>rpp</key>
    <value>10</value>
    </par>
    <par>
    <key>curry</key>
    <value>CHF</value>
    </par>
    to
    <val_date>20081004</val_date>
    <par>
    <key>rpp</key>
    <value>10</value>
    </par>
    <par>
    <key>curry</key>
    <value transcoder="CURRENCY">CHF</value>
    </par>
    I'm using WorkspaceStudio but I've some troubles in my xquery transformation.
    I tried as below:
    <ns1:val_date>{ data($dummyProviderEvent/ns0:val_date) }</ns1:val_date>
    for $par in $dummyProviderEvent/ns0:par
    return
    <ns1:par>
    <ns1:key>{ data($par/ns0:key) }</ns1:key>
    if ($par/ns0:key="curry") then <ns1:value transcoder="CURR">{ data($par/ns0:value) }</ns1:value>
    else <ns1:value>{ data($par/ns0:value) }</ns1:value>
    </ns1:par>
    </ns1:dummyEvent>
    but is not working:
    i) WorkspaceStudio raises a warning at 'else' line with message "XML element does not match the target schema"
    ii) testing the transformation it seems that if condition is always true
    Could you help me to find out the correct solution ?
    Regards
    ferp

    I know there were some changes to the packaging of the public API in 3.0. You may want to be sure you include all the necessary jar in your classpath. I think there is another post in the forum covering this.
    Gregory Haardt
    ALSB Prg. Manager
    [email protected]

  • Help on XQuery transformation

    Hello Friends,
    I am trying to do a XQuery transformation which does not like straight one to one. I am not an expert so I don't know what I am trying to achieve is capable or not.
    So please Guys me ...
    My Source Element are like :
    <Node1>
    <Node2>
    <Node3>
    <Node4>
    <Node5>
    <Node6>
    My Destination elements are :
    <Dest1>
    <Dest2>
    <Dest3>
    <Dest4>
    Now in transformation I need put some logic like this :
    1. check if node1 and node 2 has some data then copy node1 + node 2 data in Data1 othwise if node 2 present then copy only node 2 data.
    2. similary if node 1 and node 2 node are not present then copy node 3 (if present) in dest 1 and node 4 data in dest2 subsequently.
    So, like this different combination of source nodes data will map to 4 destination nodes.
    I am trying my hands but no success yet.
    So please help me.If it is possible then can anyone write a simple example for this.
    Thanking in Anticipation.

    For the conditional part check http://www.w3schools.com/xquery/xquery_syntax.asp
    and to combine the nodes check http://www.xqueryfunctions.com/xq/fn_concat.html
    hth,
    Peter Paul

  • OSB - help in XQuery

    Hi,
    I am having a replace in proxy service to transform AIA format to custom format.
    I have a XQuery file for this.
    In Replace :
    XPath - .
    In variable - body
    Expression - browsed the xquery resource
    - in bind variables:
    variable name - createssalesorder1
    binding - $body (what should I give for binding??)
    Replace node contents
    The XQuery file is :
    (:: pragma bea:global-element-parameter parameter="$createSalesOrder1" element="ns5:CreateSalesOrder" location="../../aia_11_1/AIAComponents/EnterpriseObjectLibrary/Core/EBO/SalesOrder/V2/SalesOrderEBM.xsd" ::)
    (:: pragma bea:global-element-return element="ns1:order" location="../schemas/ean.ucc/order/Order.xsd" ::)
    declare namespace ns2 = "http://xmlns.oracle.com/EnterpriseObjects/Core/Custom/EBO/SalesOrder/V2";
    declare namespace ns1 = "urn:ean.ucc:order:2";
    declare namespace ns4 = "http://xmlns.oracle.com/EnterpriseObjects/Core/Common/V2";
    declare namespace ns3 = "http://xmlns.oracle.com/EnterpriseObjects/Core/Custom/Common/V2";
    declare namespace ns0 = "urn:ean.ucc:2";
    declare namespace ns5 = "http://xmlns.oracle.com/EnterpriseObjects/Core/EBO/SalesOrder/V2";
    declare namespace xf = "http://tempuri.org/df.om_1.0/transforms/AIASalesOrder2GS1OrderProxy/";
    declare function xf:AIASalesOrder2GS1OrderProxy($createSalesOrder1 as element(ns5:CreateSalesOrder))
    as element(ns1:order) {
    <ns1:order>
    <orderIdentification>
    <uniqueCreatorIdentification>{ fn:string($createSalesOrder1/ns4:Identification/ns4:ID/@schemeID) }</uniqueCreatorIdentification>
    <contentOwner>
    <additionalPartyIdentification>
    <additionalPartyIdentificationType>BUYER_ASSIGNED_IDENTIFIER_FOR_A_PARTY</additionalPartyIdentificationType>
    </additionalPartyIdentification>
    </contentOwner>
    </orderIdentification>
    <orderPartyInformation>
    <seller>
    <additionalPartyIdentification>
    <additionalPartyIdentificationType>SUPPLIER_ASSIGNED_IDENTIFIER_FOR_A_PARTY</additionalPartyIdentificationType>
    </additionalPartyIdentification>
    </seller>
    </orderPartyInformation>
    </ns1:order>
    declare variable $createSalesOrder1 as element(ns5:CreateSalesOrder) external;
    xf:AIASalesOrder2GS1OrderProxy($createSalesOrder1)
    When I test the proxy service using console, I get
         BEA-382513: OSB Replace action failed updating variable "body": Error parsing XML: {err}XP0006: "element {http://schemas.xmlsoap.org/soap/envelope/}Body { {http://www.w3.org/2004/07/xpath-datatypes}untypedAny }": bad value for type element {http://xmlns.oracle.com/EnterpriseObjects/Core/EBO/SalesOrder/V2}CreateSalesOrder { {http://www.w3.org/2001/XMLSchema}anyType }
    I am new to XQuery and any help on where am I going wrong on this?
    Also is there an example/tutorial for the above scenario?
    Thanks
    Ganesh

    Hello Ganesh,
    Try with "$body/*" in the binding.
    If it does not work then please paste the input xml of the proxy here. Actualiy, your proxy's input xml must be having an element of type "ns5:CreateSalesOrder" and you have to give that element's X-path in Xquery binding.
    Regards,
    Anuj

  • Need help with XQuery

    I have 2 xml documents Team and Player
    Here is how they look like
    team.xml
    <Teams>
      <Team>
      <Lost>59</Lost>
      <Name>NewYork</Name>
      <Won>103</Won>
      </Team>
      <Team>
      </Team>
    <Teams>
    player.xml
    <Players>
      <Player>
      <Age>24</Age>
      <Team>NewYork</Team>
      <BOB>67</BOB>
      <SOT>265</SOT>
      <IPT>229.3</IPT>
      </Player>
      <Player>
      </Player>
    <Players>I want to write a xquery to dsiplay for each team; the number of good* players, the avg age of good players, the number of total players and avg age of total players.
    The criteria for a good player is (BOB + SOT) / IPT < 0.91.
    This what I tried
    for $x in distinct-values (doc("team.xml")/Teams/Team/Team)
    let $y:= doc("player.xml")/Players/Player[Team=$x]
    return
    <Team>
         <Team_Name>{data($x)}</Team_Name>
         <Total_players>{count($y)}</Total_players>
         <Average_Age>{avg($y/Age)}</Average_Age>
    </Team>Using this I get the the number of total players and avg age of total players. However, i'm not sure how I can modify this to return the information about good players as well.
    Can someone please help me with this.
    Thanks.

    Try something like this
    xquery version "1.0";
    <Table>
    for $x in distinct-values (doc("team.xml")/Teams/Team/Name)
         let $y:= doc("player.xml")/Players/Player[Team=$x]
         let $z:= $y[(BOB + SOT) div IPT < 0.91]
         return
         <Team>
              <Team_Name>{data($x)}</Team_Name>
              <Total_players>{count($y)}</Total_players>
              <Good_players>{count($z)}</Good_players>
              <Average_Age>{avg($y/Age)}</Average_Age>
              {for $p in $y
              return
                   <PlayerRating>
                        {$p/Age}
                        <GoodPlayer>{$p/BOB + $p/SOT div $p/IPT lt 0.91}
                        </GoodPlayer>
                        <PlayerScore>
                        {$p/BOB + $p/SOT div $p/IPT}
                        </PlayerScore>
                   </PlayerRating>
         </Team>
    </Table>HTH,
    chris
    Edited by: chrisis on Nov 28, 2009 1:59 PM

  • Help on XQuery Retrieval

    I'm having a problem understanding the results of a Return in a FLWOR. Basically I want the second part of the XQuery to operate on the total return of the first part.
    I have a series of documents in one collection. Each document at the top level has the tag <flight-data> which has an aircraft ID as an attribute. Then within the document, there is lower level data under the tag <maintenance-raw-data> that contains fault IDs.
    An example of two of the documents in the collection:
    <flight-data aircraft-id = “1”>
    <maintenance-raw-data fault-id=“0001”>
    <maintenance-raw-data fault-id=“0002”>
    <maintenance-raw-data fault-id=“0003”>
    <maintenance-raw-data fault-id=“0001”>
    </flight-data>
    <flight-data aircraft-id = “2”>
    <maintenance-raw-data fault-id=“0002”>
    <maintenance-raw-data fault-id=“0003”>
    <maintenance-raw-data fault-id=“0003”>
    <maintenance-raw-data fault-id=“0004”>
    <maintenance-raw-data fault-id=“0005”>
    </flight-data>
    So the intent of the xquery was to select all the data for one or more aircraft, then on that “total” selection, get a distinct list of all fault IDs. The xquery is as follows:
    for $z in collection("brickdata2")/flight-data
    where $z/@aircraft-id="1" or $z/@aircraft-id="2") return
    for $x in distinct-values($z//maintenance-raw-data/@fault-id) return $x
    Basically, I want the query to return the flight-data for both aircraft and then, on that total return, find the unique fault IDs. However, the second part operates on the unique fault IDs for each aircraft separately. It gives the unique fault IDs for the first aircraft and then the unique fault IDs for the second aircraft.
    Query results with Aircraft 1 and Aircraft 2 in Where clause
    Fault ID 0001
    Fault ID 0002
    Fault ID 0003
    Fault ID 0002
    Fault ID 0003
    Fault ID 0004
    Fault ID 0005
    So we then changed the first line of the XQuery to “let $z := collection”. etc.” and then the query retrieving both aircraft works (you get 0001, 0002, 0003, 0004, 0005) “ but if you change the where clause to retrieve for only one aircraft (either one), you get the same answer (i.e., fault IDs for both aircraft).
    Appreciate any help. Thanks in advance.

    Basically, I want the query to return the flight-data for both aircraft and then, on that total return, find the unique fault IDs. However, the second part operates on the unique fault IDs for each aircraft separately. It gives the unique fault IDs for the first aircraft and then the unique fault IDs for the second aircraft.You can do it like the following, by first retrieving the whole sequence of attributes for both aircrafts, then applying distinct-values() :
    distinct-values(
      for $z in collection("brickdata2")/flight-data
      where $z/@aircraft-id = "1"
         or $z/@aircraft-id = "2"
      return $z/maintenance-raw-data/@fault-id
    )

  • Need help with Xquery Syntax.

    Hi there,
    I am using a Berkeley XML DB and I have a xquery which I need to execute in a particular format. I have the following xquery:
    for $a in collection("test.dbxml")/Bookstore/Book where $a/book_ID/text() eq "6" return $a/book_ID/text()
    This xquery runs fine and I have the end result to be 6.
    I need the same result to be specified in a XML TAG like <order_ID> 6 </order_ID> for which I have the following xquery:
    for $a in collection"test.dbxml")/Bookstore/Book where $a/book_ID/text() eq "6" return <order_ID>$a/book_ID/text()</order_ID>
    This xquery runs but return me back with the string "<order_ID>$a/book_ID/text()</order_ID>".
    Can you please help me to correct the above output to result in "<order_ID> 6 </order_ID>"
    Thanks.

    Try
    for $a in collection("test.dbxml")/Bookstore/Book
    where $a/book_ID/text() eq "6"
    return <order_ID>{$a/book_ID/text()}</order_ID>Lauren Foutz
    Edited by: LaurenFoutz on Apr 17, 2009 9:41 AM

  • Help with XQuery in OSB

    Hi!
    I'm having trouble trying to build an XQuery expression in OSB. I defined a "do" action where I iterate over elements of XML. There I defined an assign action to get each Country Name element using expression "$query/Countryl[$index]/Name/text()" where $query contains following XML document and $index contains current index for each do iteration.
    <Countries>
    <Country>
    <Name>France</Name>
    </Country>
    <Country>
    <Name>UK</Name>
    </Country>
    </Countries>
    The problem is I'm getting same "France" value as expression result for every iteration. If I replace query with "$query/Countryl[1]/Name/text()" or "$query/Countryl[2]/Name/text()" then I get correct "France" and "UK" values.
    Could anyone give me any advice?
    Thank you in advance.

    I resolved it with $query/Countryl[xs:integer($index)]/Name/text()
    Thank you.

  • I need an urgent help for  Xquery tranformation failed on OSB.

    I have made an xq then imported it into my proxyService, but when I call my proxyService I get the following error.
    here is the response of my proxyService call.
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    <soapenv:Body>
    <soapenv:Fault>
    <faultcode>soapenv:Server</faultcode>
    <faultstring>BEA-382513: ALSB Replace action failed updating variable "body": Error parsing XML: {err}XP0006: "element {http://schemas.xmlsoap.org/soap/envelope/}Body { {http://www.w3.org/2004/07/xpath-datatypes}untypedAny }": bad value for type element {http://skat.dk/begrebsmodel/2009/01/15/}EFIBetalingOrdningMisligholdt_I { {http://www.w3.org/2001/XMLSchema}anyType }</faultstring>
    <detail>
    <con:fault xmlns:con="http://www.bea.com/wli/sb/context">
    <con:errorCode>BEA-382513</con:errorCode>
    <con:reason>ALSB Replace action failed updating variable "body": Error parsing XML: {err}XP0006: "element {http://schemas.xmlsoap.org/soap/envelope/}Body { {http://www.w3.org/2004/07/xpath-datatypes}untypedAny }": bad value for type element {http://skat.dk/begrebsmodel/2009/01/15/}EFIBetalingOrdningMisligholdt_I { {http://www.w3.org/2001/XMLSchema}anyType }</con:reason>
    <con:location>
    <con:node>RouteNode1</con:node>
    <con:path>request-pipeline</con:path>
    </con:location>
    </con:fault>
    </detail>
    </soapenv:Fault>
    </soapenv:Body>
    </soapenv:Envelope>

    are you replacing the body-tag instead the first child of the body, in your case EFIBetalingOrdningMisligholdt_I
    first do a test like
    in your xquery return something like
    <EFIBetalingOrdningMisligholdt_I></EFIBetalingOrdningMisligholdt_I>
    in your proxy service do something like
    replace ./* in body with ....your xquery call result
    and see if this works
    i think your replacing content at the wrong 'level'

  • Help on Xquery writing

    I have a table as below ; and i get to a record in the table using the primary key
    create table raees_test
    unique_rec_id varchar2(16) not null primary key ,
    racn_nbr number(5),
    blob_value blob,
    invoice_data SYS.XMLTYPE
    I want to query the xml type column using Xquery where I want to reach to it through the unique_rec_id
    please let me know how to implement the query
    Thanks
    Raees

    Basically, I want the query to return the flight-data for both aircraft and then, on that total return, find the unique fault IDs. However, the second part operates on the unique fault IDs for each aircraft separately. It gives the unique fault IDs for the first aircraft and then the unique fault IDs for the second aircraft.You can do it like the following, by first retrieving the whole sequence of attributes for both aircrafts, then applying distinct-values() :
    distinct-values(
      for $z in collection("brickdata2")/flight-data
      where $z/@aircraft-id = "1"
         or $z/@aircraft-id = "2"
      return $z/maintenance-raw-data/@fault-id
    )

  • OSB - XQuery - line 7, col 2: {err}FORG0005: expected exactly 1 item, got 0

    Hi,
    I am trying to execute the below sample XQuery. Eclipse designer does not show any error. However on executing the XQuery, I get the following error "+Error executing the XQuery transformation: line 7, column 2: {err}FORG0005: expected exactly one item, got 0 items+". Appreciate your help.
    xquery version "1.0" encoding "UTF-8";
    declare namespace xf = "http://tempuri.org/OSB%20Project%201/Ids/";
    declare function xf:Ids()
    as element() {*
    *     let $abc := <catalog><product dept="MEN"><number>784</number><name language="en">Cotton Dress Shirt</name><colorChoices>white gray</colorChoices><desc>Our favorite shirt!</desc></product></catalog>*
    *     for $product in $abc/catalog/product*
    *     let $name := $product/name*
    *     where $product/@dept = "ACC"*
    *     order by $name*
    *     return $name*
    xf:Ids()

    Thanks, for the answer.
    I just tweeked my XQuery:Var = $abc a little and ended up with same issue. Request your help again.
    xquery version "1.0" encoding "UTF-8";
    declare namespace xf = "http://tempuri.org/OSB%20Project%201/Ids/";
    declare function xf:Ids() as element(*)? {
    let $abc := +<catalog><product dept="MEN" xmlns="http://datypic.com/prod"><number>784</number><name language="en">Cotton Dress Shirt</name><colorChoices>white gray</colorChoices><desc>Ou<i>favorite</i> shirt! </desc></product><product dept="ACC"><number>563</number><name language="en">Floppy Sun Hat</name></product><product dept="ACC"><number>443</number><name language="en">Deluxe Travel Bag</name></product><product dept="MEN"><number>784</number><name language="en">Cotton Dress Shirt</name><colorChoices>white gray</colorChoices><desc>Ou<i>favorite</i> shirt! </desc></product><product dept="WMN"><number>557</number><name language="en">Fleece Pullover</name><colorChoices>navy black</colorChoices></product></catalog>+
    --(:<catalog><product dept="ACC"><number>784</number><name language="en">Cotton Dress Shirt</name><colorChoices>white gray</colorChoices><desc>Our favorite shirt!</desc></product></catalog>:)--
    for $product in $abc/product
    let $name := $product/name
    where $product/@dept = "ACC"
    order by $name
    return $name
    xf:Ids()

  • OSb-XQuery-TypeConversion(decimal to int)

    Hi all,
    I need some help in Xquery Transformation
    Source element type is decimal
    target element type is int
    I need to convert to decimal to int in Xquery.
    Actually I tried like this way
    <targetElement>{xs:int($sourceElement)}</targetElement>
    <error>Error occurred while executing XQuery: {err}XP0021: "100.00": can not cast to {http://www.w3.org/2001/XMLSchema}integer: error: integer: Invalid integer value: 100.00. Either the XQuery is invalid or it contains custom XQuery functions. Try using the web test console to test this XQuery (Right click on the XQuery file and select Run As ->Run On Server) </error>
    Can u help on this ,Which function do I need to use for type casting in Xquery.
    Regards
    Krishna.

    It's tricky because when you convert from xs:string to xs:integer decimal point is not allowed... So you have to go around and convert to xs:decimal first...
    <targetElement>{xs:int(xs:decimal($sourceElement))}</targetElement>
    Hope this answers your question...
    Cheers,
    Vlad

  • OSB XQuery transformation help in Proxy Service

    Hi,
    Need help in transformation of the below input to a proxy service
    <soapenv:Body  xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
       <InputParams>
         <queryParams>
           <quer:query-params  xmlns:quer="http://www.example.org/QueryParams">
            <param name="test51" value="val3353" />
            <param name="test1" value="val2" />
            <param name="test3" value="val3" />
            <param name="test4" value="val4" />
            <param name="test1" value="val1" />
            <param name="test1" value="val11" />
            <param name="test8" value="val33" />
            <param name="test1" value="val34" />
            <param name="test8" value="val33" />
            <param name="test81" value="val33" />
            <param name="test1" value="val333" />
            <param name="test38" value="val33" />
           </quer:query-params>
         </queryParams>
       </InputParams>
    </soapenv:Body> and want to have the below output after running the below XQuery transformation
    <ns0:mparams>
      <ns0:param name="test1" value="val2" />
      <ns0:param name="test1" value="val1" />
      <ns0:param name="test1" value="val11" />
      <ns0:param name="test1" value="val34" />
      <ns0:param name="test1" value="val333" />
    </ns0:mparams>this is the xquery transformation file
    (:: pragma  parameter="$InputQuery" type="anyType" ::)
    (:: pragma bea:global-element-return element="ns0:mparams" location="../xsd/TargetParams.xsd" ::)
    declare namespace ns0 = "http://www.example.org/QueryParams";
    declare namespace xf = "http://tempuri.org/Simple/transformation/listparams/";
    declare function xf:listparams($InputQuery as element(*))
        as element(ns0:mparams) {
            <ns0:mparams>
                { $InputQuery/ns0:params/param[@name="test1"] }
            </ns0:mparams>
    declare variable $InputQuery as element(*) external;
    xf:listparams($InputQuery)and here is the input to the above .qs
    $body/InputParams/queryParams/qp:query-paramsbut it's the output is always empty and here is what it comes out no matter what the input I give even tried the below inputs but no use
    $body/InputParams/queryParams/qp:query-params
    $body/InputParams/queryParamshere is the output it always prints when logging in the log file
    <quer:mparams xmlns:quer="http://www.example.org/QueryParams"/>Any help is appreciated.
    Thanks

    $InputQuery/ns0:params/param[@name="test1"]Input doesn't have a ns0:params node ..so the xpath here should be $InputQuery/param[@name="test1"]

  • Help - Nested XMLQuery (XQuery) Syntax

    I need to query a relational table that includes an XMLType column as Binary XML.  The XMLType column contains an XML document of arbitrary length. My query is in part dependent on relational column values and data values within the XML documents.  The body of the XML document, beneath the root element, is composed of 3 main sections (elements): Header1, 1/document; Header2, 1/document; and Details, 1/document.  The Details section is composed of multiple, arbitrary in number, Detail sections (elements). Example data and table layout are below.
    For a particular TLID or CUST, or SHIP_DATE, etc. I need to return the Header1, Header2, and multiple Detail sections where element values within particular Detail sections match additional qualifications.
    If I just want to return the Detail sections, I can do this successfully with the following query:
    select cust,  tlid,  xmlquery('declare default element namespace "http://abhist.acme.com:8080/acme/schema/C52R09_v2.xsd"; (::)
                            for $i in /C52R09/DETAILS/DETAIL
                            where $i/OrderNumber = "SBC00999"
                            return $i' PASSING xml_doc
                            RETURNING CONTENT).getClobVal() detail
    from xml_truck_info
    where tlid = '424500'
        and  xmlexists('declare default element namespace "http://abhist.acme.com:8080/acme/schema/C52R09_v2.xsd"; (::)
                     $x/C52R09/HEADER1[TruckNumber = "424500"]' PASSING xml_doc AS "x");
    I need, however, to return the Header1 and Header2 sections once per document if the query returns any Detail sections, regardless of  whether the query returns 1 or multiple Detail sections.
    My impression is that this will require a nested XQuery.  I haven't had success getting the syntax correct for this.  I've wasted a tremendous amount of time searching the web for examples that would replicate my scenario.  It seems there is a dearth of detailed, clear info and examples available on Oracle's XQuery implementation and structure.  I found a few examples that approximate what I'm trying to do; however, when I tweak them, the query spits up.
    Based on the following 2 examples pulled from the web or Oracle documentation:
    SELECT rownum, XMLQuery(
       <counties>
        {for $c in ora:view("CHAMBER_OF_COMMERCE")
         let $coc_county := $c/ROW/COC_COUNTY/text(),
             $coc_name := $c/ROW/COC_NAME,
             $coc_phone := $c/ROW/COC_PHONE/textb()
         where $coc_county = $cc_county/county/text()
         order by $coc_county
         return
            <county population="{xs:unsignedInt(sum(/cities/city/population))}">
               <name>{$coc_county}</name>
               <chamber phone="{$coc_phone}">{$coc_name/text()}</chamber>
               <attractions>
                  {for $a in collection("/public")
                   where $coc_county = $a/attraction/county/text()
                   return $a
               </attractions>
            </county>}
        </counties>
        PASSING BY VALUE cc_city_populations,
           XMLTYPE('<county>' || cc_county || '</county>') AS "cc_county"
        RETURNING CONTENT)
    FROM county_census;
    and
    SELECT XMLQuery(
    'for $i in $h//channel
    return
    <headlines>
    <title>OTN new articles on Oracle Solaris</title>
    <items>
         for $j in $h//item
         where ora:contains($j, "Oracle Solaris")
         return <item> {($j/title, $j/link)}</item>
    </items>
    </headlines>'
    PASSING xmlparse (document httpuritype ('http://feeds.delicious.com/v2/rss/OracleTechnologyNetwork/
    otntecharticle').getCLOB()) as "h"
    RETURNING CONTENT).getStringVal() as RESULT FROM DUAL;
    I have modified my simple, successful query above to the following:
    select tlid, XMLQuery('declare default element namespace "http://abhist.acme.com:8080/acme/schema/C52R09_v2.xsd"; (::)
                  for $i in /C52R09
                  return
                    <Headers>
                      "{$i/Header1}"
                      "{$i/Header2}"
                    </Headers>
                        for $x in $i/DETAILS/DETAIL
                        where $x/MarvinOrderNumber = "SBC00999"
                        return $x
                    PASSING xml_doc
                  RETURNING CONTENT).getClobVal() detail
    from xml_truck_info
    where TLID = '424500'
        and  xmlexists('declare default element namespace "http://abhist.acme.com:8080/acme/schema/C52R09_v2.xsd"; (::)
                     $x/C52R09/HEADER1[TruckNumber = "424500"]' PASSING xml_doc AS "x");
    When run in SQLDeveloper the result consistently reflects an issue with the curly braces '{}' around the second 'for' expression.  I have run this with different iterations, to include removing the curly braces around the $i/Header1 and $i/Header2 sections.  It makes no difference.  I get similar results as follows:
    Error at Command Line:16 Column:6
    Error report:
    SQL Error: ORA-19114: XPST0003 - error during parsing the XQuery expression:
    LPX-00801: XQuery syntax error at '{'
    9                   {
    -                   ^
    19114. 00000 -  "error during parsing the XQuery expression: %s"
    *Cause:    An error occurred during the parsing of the XQuery expression.
    *Action:   Check the detailed error message for the possible causes.
    My table, XML_TRUCK_INFO, looks like this:
    Name                Type
    CUST                VARCHAR2(7)
    LOC                 VARCHAR2(5)
    TLID                NUMBER
    STID                NUMBER
    SHIP_DATE           DATE
    SHIPPED_FLAG        VARCHAR2(1)
    XML_DOC             SYS.XMLTYPE STORAGE BINARY    
    Here is a sample of the XML_DOC content that I am running  the XQuery against.
    <?xml version="1.0" standalone="yes"?>
    <C52R09 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamspaceSchemaLocation="http://abhist.acme.com:8080/acme/schema/C52R09_v2.xsd                                           
            http://abhist.acme.com:8080/acme/schema/C52R09_v2.xsd">
      <HEADER1>
        <TruckNumber>424500</TruckNumber>
        <StopID>16</StopID>
        <ShipFrom>CITYNAME</ShipFrom>
        <ShippingDate>10-JUN-2013</ShippingDate>
        <PlannedDepartureDate>10-JUN-2013 05:00</PlannedDepartureDate>
        <ETADate>11-JUN-2013</ETADate>
        <LoadName>SW 29</LoadName>
        <StopName>16-FREEPORT, </StopName>
        <StopComment/>
        <TruckStatus>INVOICED</TruckStatus>
        <ReportType>C</ReportType>
      </HEADER1>
      <HEADER2>
        <DestAddrName>CUSTOMER-BUSINESS-NAME</DestAddrName>
        <DestAddrLine1>23 EAST 4TH AVENUE</DestAddrLine1>
        <DestAddrLine2/>
        <DestCity/>
        <DestState/>
        <DestZip>55555</DestZip>
      </HEADER2>
      <DETAILS>
        <DETAIL>
          <OrderNumber>SBC00999</OrderNumber>
          <LineNumber>3</LineNumber>
          <OrderType>STANDARD SALES ORDER</OrderType>
          <OrderStatus>SHIPPED COMPLETE</OrderStatus>
          <OrderDate>23-MAY-2013</OrderDate>
          <JobName>Job1</JobName>
          <QtyOrdered>3</QtyOrdered>
          <QtyShipped>3</QtyShipped>
          <WeekofDelivery>10-JUN-2013</WeekofDelivery>
          <Status>THIS TRUCK</Status>
          <CustomerNumber>5000-000</CustomerNumber>
          <CustomerName>CUSTNAME1</CustomerName>
          <CustomerPONumber>W163409</CustomerPONumber>
          <CubicFeet>4.56</CubicFeet>
          <ListPrice>677</ListPrice>
          <SpecialMQSCode>
            <ProductType>AAZG</ProductType>
            <UnitType>ABEG</UnitType>
          </SpecialMQSCode>
          <ShortDescription>INSERT ASSEMBLY</ShortDescription>
          <OpeningCount>5</OpeningCount>
          <TrackingLines>
            <TrackingNo>0YD746</TrackingNo>
            <TrackingStatus>Shipped</TrackingStatus>
            <ScanData>
              <ScanDate>11-JUN-2013 07:05</ScanDate>
              <Signature>mark</Signature>
              <ScanStatus>SCANNED</ScanStatus>
            </ScanData>
            <TrackingNo>0YD747</TrackingNo>
            <TrackingStatus>Shipped</TrackingStatus>
            <ScanData>
              <ScanDate>11-JUN-2013 07:31</ScanDate>
              <Signature>mark</Signature>
              <ScanStatus>SCANNED</ScanStatus>
            </ScanData>
            <TrackingNo>0YD748</TrackingNo>
            <TrackingStatus>Shipped</TrackingStatus>
            <ScanData>
              <ScanDate>11-JUN-2013 07:06</ScanDate>
              <Signature>mark</Signature>
              <ScanStatus>SCANNED</ScanStatus>
            </ScanData>
          </TrackingLines>
        </DETAIL>
        <DETAIL>
          <OrderNumber>SBC00999</OrderNumber>
          <LineNumber>4</LineNumber>
          <OrderType>STANDARD SALES ORDER</OrderType>
          <OrderStatus>SHIPPED COMPLETE</OrderStatus>
          <OrderDate>23-MAY-2013</OrderDate>
          <JobName>Job1</JobName>
          <QtyOrdered>3</QtyOrdered>
          <QtyShipped>3</QtyShipped>
          <WeekofDelivery>10-JUN-2013</WeekofDelivery>
          <Status>THIS TRUCK</Status>
          <CustomerNumber>5000-000</CustomerNumber>
          <CustomerName>CUSTNAME1</CustomerName>
          <CustomerPONumber>W163409</CustomerPONumber>
          <CubicFeet>4.56</CubicFeet>
          <ListPrice>677</ListPrice>
          <SpecialMQSCode>
            <ProductType>AAZG</ProductType>
            <UnitType>ABEG</UnitType>
          </SpecialMQSCode>
          <ShortDescription>INSERT ASSEMBLY</ShortDescription>
          <OpeningCount>5</OpeningCount>
          <TrackingLines>
            <TrackingNo>0YD749</TrackingNo>
            <TrackingStatus>Shipped</TrackingStatus>
            <ScanData>
              <ScanDate>11-JUN-2013 07:05</ScanDate>
              <Signature>mark</Signature>
              <ScanStatus>SCANNED</ScanStatus>
            </ScanData>
            <TrackingNo>0YD750</TrackingNo>
            <TrackingStatus>Shipped</TrackingStatus>
            <ScanData>
              <ScanDate>11-JUN-2013 07:05</ScanDate>
              <Signature>mark</Signature>
              <ScanStatus>SCANNED</ScanStatus>
            </ScanData>
            <TrackingNo>0YD751</TrackingNo>
            <TrackingStatus>Shipped</TrackingStatus>
            <ScanData>
              <ScanDate>11-JUN-2013 06:46</ScanDate>
              <Signature>mark</Signature>
              <ScanStatus>SCANNED</ScanStatus>
            </ScanData>
          </TrackingLines>
        </DETAIL>
        <DETAIL>
          <OrderNumber>SBC00999</OrderNumber>
          <LineNumber>5</LineNumber>
          <OrderType>STANDARD SALES ORDER</OrderType>
          <OrderStatus>SHIPPED COMPLETE</OrderStatus>
          <OrderDate>23-MAY-2013</OrderDate>
          <JobName>Job1</JobName>
          <QtyOrdered>2</QtyOrdered>
          <QtyShipped>2</QtyShipped>
          <WeekofDelivery>10-JUN-2013</WeekofDelivery>
          <Status>THIS TRUCK</Status>
          <CustomerNumber>5000-000</CustomerNumber>
          <CustomerName>CUSTNAME1</CustomerName>
          <CustomerPONumber>W163409</CustomerPONumber>
          <CubicFeet>4.56</CubicFeet>
          <ListPrice>677</ListPrice>
          <SpecialMQSCode>
            <ProductType>AAZG</ProductType>
            <UnitType>ABEG</UnitType>
          </SpecialMQSCode>
          <ShortDescription>INSERT ASSEMBLY</ShortDescription>
          <OpeningCount>5</OpeningCount>
          <TrackingLines>
            <TrackingNo>0YD752</TrackingNo>
            <TrackingStatus>Shipped</TrackingStatus>
            <ScanData>
              <ScanDate>11-JUN-2013 07:05</ScanDate>
              <Signature>mark</Signature>
              <ScanStatus>SCANNED</ScanStatus>
            </ScanData>
            <TrackingNo>0YD753</TrackingNo>
            <TrackingStatus>Shipped</TrackingStatus>
            <ScanData>
              <ScanDate>11-JUN-2013 07:42</ScanDate>
              <Signature>mark</Signature>
              <ScanStatus>SCANNED</ScanStatus>
            </ScanData>
          </TrackingLines>
        </DETAIL>
        <DETAIL>
          <OrderNumber>SBC01011</OrderNumber>
          <LineNumber>1</LineNumber>
          <OrderType>STANDARD SALES ORDER</OrderType>
          <OrderStatus>SHIPPED COMPLETE</OrderStatus>
          <OrderDate>28-MAY-2013</OrderDate>
          <JobName>Job2</JobName>
          <QtyOrdered>4</QtyOrdered>
          <QtyShipped>4</QtyShipped>
          <WeekofDelivery>10-JUN-2013</WeekofDelivery>
          <Status>THIS TRUCK</Status>
          <CustomerNumber>5000-000</CustomerNumber>
          <CustomerName>CUSTNAME1</CustomerName>
          <CustomerPONumber>W163766</CustomerPONumber>
          <CubicFeet>4.6</CubicFeet>
          <ListPrice>823</ListPrice>
          <SpecialMQSCode>
            <ProductType>AAZG</ProductType>
            <UnitType>ABEG</UnitType>
          </SpecialMQSCode>
          <ShortDescription>INSERT ASSEMBLY</ShortDescription>
          <OpeningCount>5</OpeningCount>
          <TrackingLines>
            <TrackingNo>0YV016</TrackingNo>
            <TrackingStatus>Shipped</TrackingStatus>
            <ScanData>
              <ScanDate>11-JUN-2013 07:46</ScanDate>
              <Signature>mark</Signature>
              <ScanStatus>SCANNED</ScanStatus>
            </ScanData>
            <TrackingNo>0YV017</TrackingNo>
            <TrackingStatus>Shipped</TrackingStatus>
            <ScanData>
              <ScanDate>11-JUN-2013 07:25</ScanDate>
              <Signature>mark</Signature>
              <ScanStatus>SCANNED</ScanStatus>
            </ScanData>
            <TrackingNo>0YV018</TrackingNo>
            <TrackingStatus>Shipped</TrackingStatus>
            <ScanData>
              <ScanDate>11-JUN-2013 06:51</ScanDate>
              <Signature>mark</Signature>
              <ScanStatus>SCANNED</ScanStatus>
            </ScanData>
            <TrackingNo>0YV019</TrackingNo>
            <TrackingStatus>Shipped</TrackingStatus>
            <ScanData>
              <ScanDate>11-JUN-2013 07:22</ScanDate>
              <Signature>mark</Signature>
              <ScanStatus>SCANNED</ScanStatus>
            </ScanData>
          </TrackingLines>
        </DETAIL>
      </DETAILS>
    </C52R09>
    I would appreciate any help and/or insights from others more experienced in this than I.
    Thanks in advance,
    Paul

    Sorry, as I look back at the declaration in the root element included in the example, I must have used an older version of the data.  The root element with declarations should have been this:
    <C52R09 xmlns="http://abhist.acme.com:8080/acme/schema/C52R09_v2.xsd"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:SchemaLocation="http://abhist.acme.com:8080/acme/schema/C52R09_v2.xsd                                 
    http://abhist.acme.com:8080/acme/schema/C52R09_v2.xsd">
    I've included the query with the declaration (using data values in the table, but different from those in the example) and the result below:
    PK_XML-MOS2>>select tlid
      2       , XMLQuery('declare default element namespace "http://abhist.acme.com:8080/acme/schema/C52R09_v2.xsd"; (::)
      3           let $dtls := /C52R09/DETAILS/DETAIL[OrderNumber=$order_no]
      4            return if ($dtls) then
      5            <Doc>
      6            {
      7              <Headers>{ /C52R09/HEADER1, /C52R09/HEADER2 }</Headers>
      8            , <Details>{ $dtls }</Details>
      9            }
    10            </Doc>
    11            else ()'
    12           PASSING xml_doc
    13                 , '17Z00266' as "order_no"
    14           RETURNING CONTENT
    15         ).getClobVal() detail
    16  from xml_truck_info
    17  where tlid = 398043
    18    and xmlexists('declare default element namespace "http://abhist.acme.com:8080/acme/schema/C52R09_v2.xsd"; (::)
    19          /C52R09/HEADER1[TruckNumber=$truck_no]'
    20          PASSING xml_doc
    21                , '398043' as "truck_no"
    22        );
    More .....
          TLID  DETAIL
        398043   
    I've included the query without the declaration (same data values as above) and the result below:
    PK_XML-MOS2>>select tlid
       2       , XMLQuery('let $dtls := /C52R09/DETAILS/DETAIL[OrderNumber=$order_no]
       3            return if ($dtls) then
       4            <Doc>
       5            {
       6              <Headers>{ /C52R09/HEADER1, /C52R09/HEADER2 }</Headers>
       7            , <Details>{ $dtls }</Details>
       8            }
       9            </Doc>
      10            else ()'
      11           PASSING xml_doc
      12                 , '17Z00266' as "order_no"
      13           RETURNING CONTENT
      14         ).getClobVal() detail
      15  from xml_truck_info
      16  where tlid = 398043
      17    and xmlexists('/C52R09/HEADER1[TruckNumber=$truck_no]'
      18          PASSING xml_doc
      19                , '398043' as "truck_no"
      20        );
    no rows selected
    The first example, with the declaration, returns the TLID value, although no detail section.  Whereas, the second, without the declaration, finds nothing to return.
    Thanks again.

  • Please Help With : XVM-01003: [XPST0003]/LPX-00801: XQuery  Syntax error at

    Hi gurus,
    I need your help on using the XMLQuery function. We are FINALLY in the processing of migrating from 10g to 11gR2! Oracle says that we should replace extracValue with XMLQuery, so I am trying to do that but I am getting the errors below,
    XVM-01003: [XPST0003] Syntax error at (if I use a PL/SQL variable).
    LPX-00801: XQuery syntax error at (if I use the literals).
    I have read through many of the posts related to XMLQuery and its default element namespace, but I have no luck on that. I have an example that has this kind prefix (a part of the xml is posted here):
    <soap:Body>
    <soap:Fault xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
    <soap:Code>
    <soap:Value>soap:Sender</soap:Value>
    <soap:Subcode>
    <soap:Value>soap:InvalidMessage</soap:Value>
    </soap:Subcode>
    </soap:Code>
    <soap:Reason>
    <soap:Text xml:lang="en">UpdateCaseDetentionStatus does not apply to this case&apos;s type.</soap:Text>
    </soap:Reason>
    <soap:Node>CourtFileNumber</soap:Node>
    I need to get the Text inside the Reason node. No matter what I do with the default namespace (and if I don't declare one I also get an error), I get the following error:
    XMLQuery ('declare default element namespace s="http://www.w3.org/2003/05/soap-envelope" ; /s:Envelope/s:Body/s:Fault/s:Reason/s:Text'):
    LPX-00801: XQuery syntax error at 's'
    1 declare default element namespace s="http://www.w3.org/2003/05/soap-envelop
    - ^
    ORA-06512: at line 103
    XMLQuery('declare default element namespace xmlns:soap="http://www.w3.org/2003/05/soap-envelope" ; /soap:Envelope/soap:Body/soap:Fault/soap:Reason/soap:Text'):
    LPX-00801: XQuery syntax error at 'xmlns:soap'
    1 declare default element namespace xmlns:soap="http://www.w3.org/2003/05/soa
    - ^
    ORA-06512: at line 103
    Using the XMLTable function does not have any problems.
    What do I do wrong here? I could just use the XMLTable to replace all the extractValue(s) that I have, but I really want to learn how to make the XMLQuery correct. Please help!
    I just tried this and I got the same error:
    XMLQuery('declare default namespace s="http://www.w3.org/2003/05/soap-envelope" ; (::) $p/s:Envelope/s:Body/s:Fault/s:Reason/s:Text' passing p_XMLDoc as "p"
    Thank you.
    Ben
    Edited by: myora9i on Apr 22, 2011 1:42 PM

    Hi Ben,
    Can someone please explain to me when should I use the default key word and when I should not use it?If you declare a default namespace then all unqualified (= unprefixed) elements will be considered belonging to that namespace.
    If you declare a namespace with a prefix, you'll have to qualify each element in the XQuery.
    See below example based on your XML sample :
    DECLARE
      soap_doc xmltype := xmltype(
      '<soap:Body xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
    <soap:Fault>
    <soap:Code>
    <soap:Value>soap:Sender</soap:Value>
    <soap:Subcode>
    <soap:Value>soap:InvalidMessage</soap:Value>
    </soap:Subcode>
    </soap:Code>
    <soap:Reason>
    <soap:Text xml:lang="en">UpdateCaseDetentionStatus does not apply to this case''s type.</soap:Text>
    </soap:Reason>
    <soap:Node>CourtFileNumber</soap:Node>
    </soap:Fault>
    </soap:Body>'
      v_text  varchar2(100);
    BEGIN
      -- with a default namespace,
      -- no need to prefix each element :
      SELECT XMLCast(
        XMLQuery(
          'declare default element namespace "http://www.w3.org/2003/05/soap-envelope"; (::)
           /Body/Fault/Reason/Text'
          passing soap_doc
          returning content
        as varchar2(100)
      INTO v_text
      FROM dual;
      dbms_output.put_line(v_text);
      -- with a declared namespace prefix,
      -- each element must be qualified with the prefix :
      SELECT XMLCast(
        XMLQuery(
          'declare namespace s = "http://www.w3.org/2003/05/soap-envelope"; (::)
           /s:Body/s:Fault/s:Reason/s:Text'
          passing soap_doc
          returning content
        as varchar2(100)
      INTO v_text
      FROM dual;
      dbms_output.put_line(v_text);
    END;
    /

Maybe you are looking for

  • ITunes 7, software 1.2 videos gone from iPod

    I recently updated to iTunes 7 so that i would be able to purchase and download a show from the music store. After my iPod was finished updating with the new software all of my shows were gone from my iPod except for the one i just bought. They are s

  • Anybody experienced loss of data when switching service providers?

    I recently transferred my two IMAP accounts to a new hosting service, but since I used the same names for the new accounts in Mail, all the mailboxes under the previous accounts, with hundreds of messages dating back to over two years, were deleted o

  • HP OJP 8600 - 1970's Style Poll/Select UDP hundreds of times a second

    My new HP OJP 8600 is connected by ethernet to my router, wireless is turned off.   My new Apple MacBook Pro, with OS X9.5 has downloaded the latest HP OJP 8600 software.  So why does the OJP 8600 use UDP to communicate 1970's style poll/select messa

  • External LDAP port in Azure machine

    Hi all, I have two machines. One is used as an Active Directory domain controller machine. One is for web server. I want to capture LDAP queries by network package analysis tool but don't know if Azure machine uses different port rather than standard

  • FMX2 - earmarked funds  and SAP Content server

    Hello all, Need a help to find solution for the following issue. Customer would like to have earmarked funds   attachments  save on SAP Content server u201Eout of databaseu201C. So in detail, customer run FMX2 change document and from menu choose Env