ODSI xquery types

Hi Mike,
I used to develop in ALDSP 2.5 but I am now on the new platform 10gR3 and I noticed with the new platform the type item() is no longer supported. I didn't use it much in 2.5 but there were a couple cases where it made sense. I did find that instead of item() I can use element() which seems to have the same effect as item() did in 2.5. I tried searching and could not find information about the supported ODSI xquery types. Is there a document that lists all the supported ODSI xquery types?
Mike

Thanks for the link, I have read through that before and I was looking for something more than RDBMS xquery mappings. Anyway here is my example:
In ALDSP 2.5 sequence $input was defined as item() but when converted to ODSI an error gets triggered "type item() not supported". So I switched item() with element() and it seems to work fine. The reason I want to do this is because I have multiple version of a service running and getItemsV1 and getItemsV2 return the same shape but have different rules applied to them. I can't get rid of V1 because of consumer dependencies and I don't want to duplicate data services or functions that are typically doing the same thing. I rarely use element() as an input parameter but do you see any issue with this down the line?
declare function tns:dummyFunction($input as element()) as element(ns:foo)* {
     let $items:=
                              typeswitch($input)
                                   case $request as element(ns1:bar) return
                                             ns11:getItemsV1($request)
                                   case $request as element(ns2:baz) return
                                             ns22:getItemsV2($request)
                                   default return
return ns3:doSomethingWithItemsFromEitherV1orV2($items)
};

Similar Messages

  • Return java SimpleDateFormat type instead of the default xs:dateTime format

    It is possible to return a date timestamp in the java SimpleDateFormat instead of xs:dateTime in a data service?
    If so, how would I go about doing this? Thanks.

    I don't understand the question. xs:dateTime is an xquery type and SimpleDateFormat is a java class. You don't have both in Xquery and you don't have both in java, so when you say 'return' I don't know what you mean. Do you mean as the return type (or part of the return type) of an xquery function? The answer is 'no' - you can only return xquery types. If your client needs it, you could pass it around as an xs:string in xquery, and your client could convert it from a string to a SimpleDateFormat.

  • UPDATEXML

    Hello
    My conf :
    SQL> select * from V$VERSION;
    BANNER
    Oracle Database 11g Express Edition Release 11.2.0.2.0 - Beta
    PL/SQL Release 11.2.0.2.0 - Beta
    CORE 11.2.0.2.0 Production
    TNS for 32-bit Windows: Version 11.2.0.2.0 - Beta
    NLSRTL Version 11.2.0.2.0 - Production
    One of my XML stored document :
    SQL> SELECT v.OBJECT_VALUE
    2 FROM vol_reel_xml_2 v
    3 WHERE XMLEXISTS('$obj/vol_reel[@nvol="AF6154"]'
    4 PASSING v.OBJECT_VALUE AS "obj")
    5 AND XMLEXISTS('$obj/vol_reel/passagers/pax[@num_carte=13457934]'
    6 PASSING v.OBJECT_VALUE AS "obj")
    7 AND TO_DATE(XMLCAST(
    8 XMLQUERY('$obj/vol_reel/@datev'
    9 PASSING BY VALUE v.OBJECT_VALUE AS "obj"
    10 RETURNING CONTENT)
    11 AS VARCHAR2(12)),'YYYY-MM-DD')
    12 = TO_DATE('2012-08-31','YYYY-MM-DD');
    OBJECT_VALUE
    <?xml version="1.0" encoding="WINDOWS-1252"?>
    <vol_reel nvol="AF6154" datev="2012-08-31">
    <passagers>
    <pax num_carte="13457934">
    <nom>Lacombe</nom>
    <prenom>Serge</prenom>
    <siege>05A</siege>
    <prix>190</prix>
    </pax>
    <pax num_carte="44482340">
    <nom>Blanchet</nom>
    <prenom>Agnes</prenom>
    <siege>17D</siege>
    <prix>146</prix>
    </pax>
    </passagers>
    </vol_reel>
    I want update the "prix" element for the first pax (198 replace 190) :
    With the same predicates, the element isn't updated :
    SQL> UPDATE vol_reel_xml_2 v
    2 SET v.OBJECT_VALUE =
    3 UPDATEXML(v.OBJECT_VALUE,'/vol_reel/passagers/pax/prix/text()','198')
    4 WHERE XMLEXISTS('$obj/vol_reel[@nvol="AF6154"]' PASSING v.OBJECT_VALUE AS "obj")
    5 AND XMLEXISTS('$obj/vol_reel/passagers/pax[@num_carte=13457934]'
    6 PASSING v.OBJECT_VALUE AS "obj")
    7 AND TO_DATE(XMLCAST(
    8 XMLQUERY('$obj/vol_reel/@datev'
    9 PASSING BY VALUE v.OBJECT_VALUE AS "obj"
    10 RETURNING CONTENT)
    11 AS VARCHAR2(12)),'YYYY-MM-DD')
    12 = TO_DATE('2012-08-31','YYYY-MM-DD');
    0 rows updated.
    Any idea?
    Thanks in advance

    Thanks
    You're right, my table is created based on XML Schema :
    CREATE TABLE vol_reel_xml_2 OF XMLType
    XMLTYPE STORE AS OBJECT RELATIONAL
    XMLSCHEMA "http://www.iut-blagnac.fr/vols.xsd"
    ELEMENT "vol_reel"
    VARRAY "XMLDATA"."passagers"."pax" STORE AS TABLE pax_tabnt;
    ---xml schema (vol_reel_annote.xsd)
    <?xml version="1.0" encoding="utf-8"?>
    <xsd:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xdb:storeVarrayAsTable="true" version="1.0" xmlns:xdb="http://xmlns.oracle.com/xdb" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
         <xsd:element name="vol_reel" type="vol_reelType"/>
         <xsd:complexType name="vol_reelType" xdb:SQLType="VOL_REEL_XML_T">
              <xsd:sequence>
                   <xsd:element name="passagers" type="passagersType"/>
              </xsd:sequence>
              <xsd:attribute name="nvol" xdb:SQLType="VARCHAR2">
                   <xsd:simpleType>
                        <xsd:restriction base="xsd:string">
                             <xsd:minLength value="4"/>
                             <xsd:maxLength value="7"/>
                        </xsd:restriction>
                   </xsd:simpleType>
              </xsd:attribute>
              <xsd:attribute name="datev" type="xsd:date"/>
         </xsd:complexType>
         <xsd:complexType name="passagersType" xdb:SQLType="PASSAGERS_T">
              <xsd:sequence>
                   <xsd:element minOccurs="2" maxOccurs="180" name="pax" type="paxType" xdb:SQLCollType="PASSAGERS_VRY_T"/>
              </xsd:sequence>
         </xsd:complexType>
         <xsd:complexType name="paxType" xdb:SQLType="PASSAGERS_ELT_VRY_T">
              <xsd:sequence>
                   <xsd:element name="nom" minOccurs="1" xdb:SQLType="VARCHAR2">
                        <xsd:simpleType>
                             <xsd:restriction base="xsd:string">
                                  <xsd:minLength value="1"/>
                                  <xsd:maxLength value="30"/>
                             </xsd:restriction>
                        </xsd:simpleType>
                   </xsd:element>
                   <xsd:element name="prenom" minOccurs="1" xdb:SQLType="VARCHAR2">
                        <xsd:simpleType>
                             <xsd:restriction base="xsd:string">
                                  <xsd:minLength value="1"/>
                                  <xsd:maxLength value="30"/>
                             </xsd:restriction>
                        </xsd:simpleType>
                   </xsd:element>
                   <xsd:element name="siege" minOccurs="1" xdb:SQLType="CHAR">
                        <xsd:simpleType>
                             <xsd:restriction base="xsd:string">
                                  <xsd:minLength value="1"/>
                                  <xsd:maxLength value="3"/>
                             </xsd:restriction>
                        </xsd:simpleType>
                   </xsd:element>
                   <xsd:element name="prix" minOccurs="1" xdb:SQLType="NUMBER">
                        <xsd:simpleType>
                             <xsd:restriction base="xsd:decimal">
                                  <xsd:fractionDigits value="2"/>
                                  <xsd:totalDigits value="4"/>
                             </xsd:restriction>
                        </xsd:simpleType>
                   </xsd:element>
              </xsd:sequence>
              <xsd:attribute name="num_carte" type="xsd:int"/>
         </xsd:complexType>
    </xsd:schema>
    ----- xml schema registration
    BEGIN
    --DBMS_XMLSCHEMA.DELETESCHEMA
    -- ('http://www.iut-blagnac.fr/vols.xsd',DBMS_XMLSCHEMA.DELETE_CASCADE_FORCE);
    DBMS_XMLSCHEMA.REGISTERSCHEMA(
    SCHEMAURL => 'http://www.iut-blagnac.fr/vols.xsd',
    SCHEMADOC => BFILENAME('REPXML','vol_reel_annote.xsd'),
    LOCAL => TRUE, GENTYPES => TRUE, GENTABLES => FALSE,
    CSID => NLS_CHARSET_ID('AL32UTF8'));
    END;
    Your succesful update becomes with my configuration :
    SQL> UPDATE vol_reel_xml_2 v
    2 SET v.object_value =
    3 updateXML( v.object_value,
    4 '/vol_reel/passagers/pax[@num_carte=13457934]/prix/text()'
    5 , 198 )
    6 WHERE XMLExists('/vol_reel[@nvol="AF6154" and @datev="2012-08-31"]'
    7 passing v.object_value);
    SET v.object_value =
    ERROR at line 2:
    ORA-19162: XPTY0004 - XQuery type mismatch: invalid argument types 'xs:date',
    'xs:string' for function '='
    By translating the xsd:datetime / Oracle date :
    SQL> UPDATE vol_reel_xml_2 v
    2 SET v.object_value =
    3 updateXML( v.object_value,
    4 '/vol_reel/passagers/pax[@num_carte=13457934]/prix/text()',198)
    5 WHERE XMLExists('/vol_reel[@nvol="AF6154"]'passing v.object_value)
    6 AND TO_DATE(XMLCAST(
    7 XMLQUERY('$obj/vol_reel/@datev'
    8 PASSING BY VALUE OBJECT_VALUE AS "obj"
    9 RETURNING CONTENT)
    10 AS VARCHAR2(12)),'YYYY-MM-DD')
    11 = TO_DATE('2012-08-31','YYYY-MM-DD');
    1 row updated.
    I think my fault came from the fact I performed the test num_carte=13457934 in the UPDATE WHERE clause instead of the XPath predicate as previously.
    Thanks again

  • How can I fix a xquery resulting error ORA-19279: XPTY0004 - XQuery dynamic type mismatch: expected singleton sequence  - got multi-item sequence

    Hello,
    How can I improve the XQuery below in order to obtain a minimised return to escape from both errors ORA-19279 and ORA-01706?
    XQUERY for $book in  fn:collection("oradb:/HR/TB_XML")//article let $cont := $book/bdy  where  $cont   [ora:contains(text(), "(near((The,power,Love),10, TRUE))") > 0] return $book
    ERROR:
    ORA-19279: XPTY0004 - XQuery dynamic type mismatch: expected singleton sequence
    - got multi-item sequence
    XQUERY for $book in  fn:collection("oradb:/HR/TB_XML")//article let $cont := $book/bdy  where  $cont   [ora:contains(., "(near((The,power,Love),10, TRUE))") > 0] return $book//bdy
    /*ERROR:
    ORA-01706: user function result value was too large
    Regards,
    Daiane

    below query works for 1 iteration . but for multiple sets i am getting following error .
    When you want to present repeating groups in relational format, you have to extract the sequence of items in the main XQuery expression.
    Each item is then passed to the COLUMNS clause to be further shredded into columns.
    This should work as expected :
    select x.*
    from abc t
       , xmltable(
           xmlnamespaces(
             default 'urn:swift:xsd:fin.970.2011'
           , 'urn:swift:xsd:mtmsg.2011' as "ns0"
         , '/ns0:FinMessage/ns0:Block4/Document/MT970/F61a/F61'
           passing t.col1
           columns F61ValueDate                Varchar(40) Path 'ValueDate'
                 , DebitCreditMark             Varchar(40) Path 'DebitCreditMark'
                 , Amount                      Varchar(40) Path 'Amount'
                 , TransactionType             Varchar(40) Path 'TransactionType'
                 , IdentificationCode          Varchar(40) Path 'IdentificationCode'                 
                 , ReferenceForTheAccountOwner Varchar(40) Path 'ReferenceForTheAccountOwner'
                 , SupplementaryDetails        Varchar(40) Path 'SupplementaryDetails'       
         ) x ;

  • Not able to find a simple type in Xquery transformation

    Hi,
    In Eclipse, for Xquery transformation, i am not able to find the XMLObject simple type, under the source or target mapping simple type.
    Need help plzz
    Thanks,
    Sarat

    XMLObject is not a XML Schema data type, it is a Java data type. So you wont see it in XQuery graphical mapper. XMLObject in Java is mapped to xs:anyType in Schema. What is your exact requirement?

  • ORA-19279: XPTY0004 - XQuery dynamic type mismatch: expected singleton sequence - got multi-item sequence

    Hi ,
    I executed the below query in database version 11.2.0.3.0, it throws the error like "ORA-19279: XPTY0004 - XQuery dynamic type mismatch: expected singleton sequence - got multi-item sequence"
    with PAYMENT_XML as (
          select XMLTYPE(
            '<Document>
            <pain.002.001.02>
                <GrpHdr>
                      <MsgId>CITIBANK/20091204-PSR/4274</MsgId>
                      <CreDtTm>2009-12-04T09:36:00</CreDtTm>
               </GrpHdr>
                <OrgnlGrpInfAndSts>
                <OrgnlMsgId>10002</OrgnlMsgId>
                <OrgnlMsgNmId>pain.001.001.02</OrgnlMsgNmId>
                <OrgnlNbOfTxs>20</OrgnlNbOfTxs>
                <OrgnlCtrlSum>7000</OrgnlCtrlSum>
                <GrpSts>PART</GrpSts>
                <StsRsnInf>
                  <AddtlStsRsnInf>ACK - FILE PARTIALLY SUCCESSFUL</AddtlStsRsnInf>
                </StsRsnInf>
              </OrgnlGrpInfAndSts>
              <OrgnlGrpInfAndSts>
                <OrgnlMsgId>10001</OrgnlMsgId>
                <OrgnlMsgNmId>pain.001.001.02</OrgnlMsgNmId>
                <OrgnlNbOfTxs>202</OrgnlNbOfTxs>
                <OrgnlCtrlSum>9000</OrgnlCtrlSum>
                <GrpSts>PART</GrpSts>
                <StsRsnInf>
                  <AddtlStsRsnInf>ACK - FILE PARTIALLY SUCCESSFUL</AddtlStsRsnInf>
                  <AddtlStsRsnInf>Formated</AddtlStsRsnInf>
                </StsRsnInf>
              </OrgnlGrpInfAndSts>
          </pain.002.001.02>
      </Document>') as OBJECT_VALUE1
       from dual
      select R.*
      from PAYMENT_XML,
           XMLTABLE(
           'for $COMP in $COMPANY/Document/pain.002.001.02
              for $DEPT at $DEPTIDX in $COMP/OrgnlGrpInfAndSts
               return <RESULT>
                        <NAME>{fn:data($COMP/GrpHdr/MsgId)}</NAME>
                          $DEPT/OrgnlMsgId,
                          $DEPT/OrgnlNbOfTxs,
                          $DEPT/OrgnlCtrlSum,
                          $DEPT/GrpSts,
                          $DEPT/StsRsnInf/AddtlStsRsnInf
                      </RESULT>'
           passing OBJECT_VALUE1 as "COMPANY"
           columns
             NAME            VARCHAR(10)  path 'NAME',
             OrgnlMsgId      VARCHAR2(24) path 'OrgnlMsgId',
             ORGNLNBOFTXS    VARCHAR2(24) path 'OrgnlNbOfTxs',
             ORGNLCTRLSUM    NUMBER       path 'OrgnlCtrlSum',
             GRPSTS          VARCHAR2(24) path 'GrpSts',
             ADDTLSTSRSNINF  VARCHAR2(40) path 'AddtlStsRsnInf'
         ) r
    Errors comes this part :
                <StsRsnInf>
                  <AddtlStsRsnInf>ACK - FILE PARTIALLY SUCCESSFUL</AddtlStsRsnInf>
                  <AddtlStsRsnInf>Formated</AddtlStsRsnInf>
                </StsRsnInf>
    if i put the single statement for this xml element <AddtlStsRsnInf> it works fine if more than one element comes it raised the error.
    i want the output like the below format : want to merge the element value with (, comma)  delimiter with single coloumn value
    NAME
    ORGNLMSGID
    ORGNLNBOFTXS
    ORGNLCTRLSUM
    GRPSTS
    ADDTLSTSRSNINF
    CITIBANK/2
    10002
    20
    7,000
    PART
    ACK - FILE PARTIALLY SUCCESSFUL
    CITIBANK/2
    10001
    202
    9,000
    PART
    ACK - FILE PARTIALLY SUCCESSFUL, Formated
    Thanks is advance for reply
    Thanks,
    Chidam

    Try with XQuery string-join() function :
    ADDTLSTSRSNINF  VARCHAR2(40) path 'string-join(AddtlStsRsnInf, ", ")'

  • ODSI support for return type "PL/SQL TABLE"?

    Hello!
    We are trying to connect our ODSI to an Oracle function with return type "PL/SQL TABLE". The ODSI "wizard" (used to create the physical data service) seems to understand the interface during creation, but when executed it fails. The ODSI server complains about wrong type (PLS-00382: expression is of wrong type) when we execute it from the "test tab".
    The function's metadata is looks like this:
    <params xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xdt="http://www.w3.org/2004/07/xpath-datatypes" xmlns:pn1="ld:physical/rekondis/CALC_DEBITING" >
    <param name="RETURN_VALUE" kind="return" xqueryType="pn1:RETURN_VALUE_ROW" nativeTypeCode="1111" nativeType="PL/SQL TABLE"/>
    <param name="PIN_CASE_ID" kind="in" xqueryType="xs:decimal" nativeTypeCode="3" nativeType="NUMBER"/>
    <param name="PIN_ACTION_CODE" kind="in" xqueryType="xs:decimal" nativeTypeCode="3" nativeType="NUMBER"/>
    <param name="PI_AD_NAME" kind="in" xqueryType="xs:string" nativeTypeCode="12" nativeType="VARCHAR2"/>
    </params>
    Any ideas how we can make this work!? Or is this not even supported in ODSI 10.3?
    Thanks!
    // Mikael

    Please refer to the documentation - http://download.oracle.com/docs/cd/E13162_01/odsi/docs10gr3/datasrvc/Create%20Physical%20Data%20Services%20from%20Stored%20Procedures.html

  • ORA-19279: XPTY0004 - XQuery dynamic type mismatch: expected singleton sequ

    I have been working with XML files containing only one record. I downloaded instructions to create/insert/select and the statements below work fine for the XML files with one record. Now I have XML files with multiple records/sections, but the select statement returns ORA-19279. How would I change the create/insert/select statements to handle XML files with more than one record? There is still only one vendata section, but there are multiple VendorData sections.
    Thanks.
    1.     Create a table with an XML column:
    create table vendxml_col (
    vend_id number primary key,
    vend_doc XMLType);
    2.     Insert xml document:
    insert into vendxml_col values (1,
    XMLType(bfilename('ING_FEED', 'VenData.xml'),
    nls_charset_id('AL32UTF8')));
    3.     Query the xml columns in vendxml_col:
    select vend_id,
    a.cage, a.repl_cage, a.status, a.company1, a.company2, a.address1, a.address2,
    a.pobox, a.city, a.state, a.zip, a.country, a.phone, a.fax, a.cao, a.adpp,
    a.assoc, a.type, a.affil, a.sizex, a.pri_bus, a.type_bus, a.woman, a.sic,
    a.formerly, a.formerly2, a.comp1key, a.comp2key, a.Revseq, a.Source,
    a.RequestID
    FROM vendxml_col,
    XMLTABLE('/vendata'
    PASSING vendxml_col.vend_doc
    COLUMNS
         cage varchar2(5) PATH '/vendata/VendorData/cage',
         repl_cage varchar2(5) PATH '/vendata/VendorData/repl_cage',
         status varchar2(1) PATH '/vendata/VendorData/status',
         company1 varchar2(30) PATH '/vendata/VendorData/company1',
         company2 varchar2(30) PATH '/vendata/VendorData/company2',
         address1 varchar2(40) PATH '/vendata/VendorData/address1',
         address2 varchar2(40) PATH '/vendata/VendorData/address2',
         pobox varchar2(10) PATH '/vendata/VendorData/pobox',
         city varchar2(30) PATH '/vendata/VendorData/city',
         state varchar2(2) PATH '/vendata/VendorData/state',
         zip varchar2(20) PATH '/vendata/VendorData/zip',
         country varchar2(20) PATH '/vendata/VendorData/country',
         phone varchar2(20) PATH '/vendata/VendorData/phone',
         fax varchar2(20) PATH '/vendata/VendorData/fax',
         cao varchar2(20) PATH '/vendata/VendorData/cao',
         adpp varchar2(20) PATH '/vendata/VendorData/adpp',
         assoc varchar2(20) PATH '/vendata/VendorData/assoc',
         type varchar2(1) PATH '/vendata/VendorData/type',
         affil varchar2(1) PATH '/vendata/VendorData/affil',
         sizex varchar2(1) PATH '/vendata/VendorData/sizex',
         pri_bus varchar2(1) PATH '/vendata/VendorData/pri_bus',
         type_bus varchar2(1) PATH '/vendata/VendorData/type_bus',
         woman varchar2(1) PATH '/vendata/VendorData/woman',
         sic varchar2(4) PATH '/vendata/VendorData/sic',
         formerly varchar2(5) PATH '/vendata/VendorData/formerly',
         formerly2 varchar2(5) PATH '/vendata/VendorData/formerly2',
         comp1key varchar2(30) PATH '/vendata/VendorData/comp1key',
         comp2key varchar2(30) PATH '/vendata/VendorData/comp2key',
         Revseq varchar2(1) PATH '/vendata/VendorData/Revseq',
         Source varchar2(3) PATH '/vendata/VendorData/Source',
         RequestID varchar2(3) PATH '/vendata/VendorData/RequestID'
    ) a
    SQL*Plus: Release 10.2.0.1.0 - Production on Thu Jun 9 13:28:00 2011
    Copyright (c) 1982, 2005, Oracle. All rights reserved.
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL>select * from V$VERSION;
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    PL/SQL Release 11.2.0.1.0 - Production
    CORE 11.2.0.1.0 Production
    TNS for Linux: Version 11.2.0.1.0 - Production
    NLSRTL Version 11.2.0.1.0 - Production
    Edited by: user8058903 on Jun 9, 2011 11:28 AM

    Welcome to the XML DB forums.
    As everything in your sample XML is coming from the VendorData node, you can just include that in the XQuery string parm such as shown below. As you didn't include any sample XML, I just built a really simple test case with two VendorData nodes. As the note says, I used WITH to simulate your table/data because I was too lazy to create and populate a table in my playground.
    WITH vendxml_col AS
    (SELECT 1 vend_id,
            XMLTYPE('<vendata><VendorData><cage>c1</cage></VendorData>
            <VendorData><cage>c2</cage></VendorData></vendata>') vend_doc
       FROM dual)
    -- Above WITH used to simulate your table/data.  You only care about below
    SELECT vend_id, a.cage
      FROM vendxml_col,
           XMLTABLE('/vendata/VendorData'
                    PASSING vendxml_col.vend_doc
                    COLUMNS
                    cage    VARCHAR2(5) PATH 'cage') a;
       VEND_ID CAGE
             1 c1
             1 c2

  • How to create an XQuery for an XML type data source

    Hi,
    1.I have data contained in an XML format.
    Hence I have created a physical data source for XML type data.
    2.I have created a logical view to broker data from several disparate physical data sources.I have called this as UnifiedView.
    3.I have created a function called getUnifiedView() to obtain data from all the physical sources
    4.Upto this point, I have not faced any problems.
    5.However when i try writing a simple XQuery for the physical XML datasource such as
    $Sh-data/PublicIdentifiers/MSISDN="1234567"
    I get result as (For example):
    <HSS>
    <MSISDN> 1234567 111111 222222 </MSISDN>
    </HSS>
    Could you please help me getting the where clause output?
    I have attached the schema and XML files used for further information.
    Regards
    Vidya

    Hi mReiche,
    I later on resolved the previously mentioned error and try out the XQuery as suggested by you.
    for $MSISDN in ns0:Sh-data()/PublicIdentifiers/MSISDN
    where $MSISDN="1234567"
    return
    <HSS>
    <MSISDN>{data($MSISDN)}</MSISDN>
    </HSS>
    It works! Thanks.
    Now i am trying to retrieve data from 2 XML documents and an LDAP query.
    I have the following data sources:
    1.LDAP queried by Java Function
    2.HSS xml
    3.Presence xml
    I want to match the telephoneNumber of the LDAP with MSISDN in the HSS.xml.
    Next i want to match the SIP_URI in the HSS.xml with Contact of the Presence.xml
    Given below is the XQuery which i have written to achieve the above:
    for $x0 in ns5:FindDN($str_mailId)
    for $Sh-Data in ns2:Sh-Data()
    where $x0 = $Sh-Data/PublicIdentifiers/MSISDN
    for $presence in ns3:presence()
    where $Sh-Data/Sh-IMS-Data/SCSCFName = $presence/ns4:tuple/ns4:contact
    return
    On executing this XQuery i am getting the following error:
    java.lang.NullPointerException: null
         at weblogic.xml.query.types.XQueryAtomicType.commonSuperTypeOf(XQueryAtomicType.java:150)
         at weblogic.xml.query.types.XQueryType.comparisonTypeOf(XQueryType.java:324)
         at weblogic.xml.query.runtime.compare.GeneralAtomicComparison.compare(GeneralAtomicComparison.java:50)
         at weblogic.xml.query.runtime.compare.ComparisonIterator.fetchNext(ComparisonIterator.java:50)
         at weblogic.xml.query.iterators.GenericIterator.next(GenericIterator.java:113)
         at weblogic.xml.query.runtime.logic.BoolEffValue.exec(BoolEffValue.java:51)
         at weblogic.xml.query.runtime.logic.BoolEffValue.fetchNext(BoolEffValue.java:47)
         at weblogic.xml.query.iterators.GenericIterator.next(GenericIterator.java:113)
         at weblogic.xml.query.runtime.core.IfThenElse.fetchNext(IfThenElse.java:79)
         at weblogic.xml.query.iterators.GenericIterator.next(GenericIterator.java:113)
         at weblogic.xml.query.runtime.core.CountMapIterator.fetchNext(CountMapIterator.java:162)
         at weblogic.xml.query.iterators.GenericIterator.next(GenericIterator.java:113)
         at weblogic.xml.query.runtime.core.CountMapIterator.fetchNext(CountMapIterator.java:162)
         at weblogic.xml.query.iterators.GenericIterator.next(GenericIterator.java:113)
         at weblogic.xml.query.runtime.sequences.Exists.fetchNext(Exists.java:40)
         at weblogic.xml.query.iterators.GenericIterator.next(GenericIterator.java:113)
         at weblogic.xml.query.runtime.core.IfThenElse.fetchNext(IfThenElse.java:79)
         at weblogic.xml.query.iterators.GenericIterator.next(GenericIterator.java:113)
         at weblogic.xml.query.runtime.core.LetIterator.fetchNext(LetIterator.java:133)
         at weblogic.xml.query.iterators.GenericIterator.next(GenericIterator.java:113)
         at weblogic.xml.query.runtime.core.LetIterator.fetchNext(LetIterator.java:133)
         at weblogic.xml.query.iterators.GenericIterator.next(GenericIterator.java:113)
         at weblogic.xml.query.runtime.querycide.QueryAssassin.fetchNext(QueryAssassin.java:54)
         at weblogic.xml.query.iterators.GenericIterator.peekNext(GenericIterator.java:151)
         at weblogic.xml.query.runtime.qname.InsertNamespaces.fetchNext(InsertNamespaces.java:161)
         at weblogic.xml.query.iterators.GenericIterator.next(GenericIterator.java:113)
         at weblogic.xml.query.runtime.core.QueryIterator.fetchNext(QueryIterator.java:127)
         at weblogic.xml.query.iterators.GenericIterator.hasNext(GenericIterator.java:134)
         at weblogic.xml.query.xdbc.util.Serializer.serializeItems(Serializer.java:142)
         at com.bea.ld.server.QueryInvocation.getResult(QueryInvocation.java:461)
         at com.bea.ld.EJBRequestHandler.executeFunction(EJBRequestHandler.java:346)
         at com.bea.ld.ServerBean.executeFunction(ServerBean.java:108)
    Please find attached the XML documents which i am using.
    Could you pls let me know how to resolve this.

  • XQuery dynamic type mismatch

    Hi all, I am new to xmldb and XQuery. Having trouble with relational xmltable quering... Any help is appriciated.
    I want the following output
    id info loc
    4 stuff2 1
    5 stuff3 1
    6 stuff1 1
    7 stuff4 2
    etc....
    The problem if feel is loc does not have a relation to transaction in the data. But I get an error "XQuery dynamic type mismatch"....
    I have created a basic example below:
    SELECT a.*
    FROM "testTable",
    XMLTABLE('/root/org/transaction'
    PASSING testTable.column
    COLUMNS
    id varchar2(2) PATH '@id',
    info varchar2(50) PATH '/info',
    loc varchar2(2) PATH '@loc'
    ) a
    <root>
    <org loc="1">
    <Transaction id="4"><info>stuff2</info></Transaction>
    <Transaction id="5"><info>stuff3</info></Transaction>
    <Transaction id="6"><info>stuff1</info></Transaction>
    </org>
    <org loc="2">
    <Transaction id="7"><info>stuff4</info></Transaction>
    <Transaction id="8"><info>stuff5</info></Transaction>
    </org>
    <org loc="3">
    <Transaction id="9"><info>stuff6</info></Transaction>
    <Transaction id="10"><info>stuff7</info></Transaction>
    </org>
    </root>
    Thanks again for any help.
    Edited by: user8820504 on Jan 14, 2010 2:27 PM

    You need two distinct tables, one that maps Transactions and one that maps Orgs. Then join them on id. Something like this:
    SQL> with testTable as (
      2  select xmltype('<root>
      3  <org loc="1">
      4  <Transaction id="4"><info>stuff2</info></Transaction>
      5  <Transaction id="5"><info>stuff3</info></Transaction>
      6  <Transaction id="6"><info>stuff1</info></Transaction>
      7  </org>
      8  <org loc="2">
      9  <Transaction id="7"><info>stuff4</info></Transaction>
    10  <Transaction id="8"><info>stuff5</info></Transaction>
    11  </org>
    12  <org loc="3">
    13  <Transaction id="9"><info>stuff6</info></Transaction>
    14  <Transaction id="10"><info>stuff7</info></Transaction>
    15  </org>
    16  </root>') doc
    17  from dual)
    18  SELECT id, info, loc
    19  FROM testTable,
    20       XMLTABLE('/root/org/Transaction'
    21       PASSING testTable.doc
    22       COLUMNS
    23       id varchar2(2) PATH '@id',
    24       info varchar2(50) PATH 'info',
    25       tr xmltype PATH '.'
    26        ) trans ,
    27       XMLTABLE('/root/org'
    28       PASSING testTable.doc
    29       COLUMNS
    30       loc varchar2(2) PATH '@loc',
    31       trs xmltype PATH 'Transaction'
    32        ) orgs
    33  where extractValue(orgs.trs,'/Transaction[@id="'||id||'"]/@id') is not null ;
    ID INFO                                               LO
    4  stuff2                                             1
    5  stuff3                                             1
    6  stuff1                                             1
    7  stuff4                                             2
    8  stuff5                                             2
    9  stuff6                                             3
    10 stuff7                                             3
    Selezionate 7 righe.Max
    [My Italian Oracle blog|http://oracleitalia.wordpress.com/2010/01/10/crittografia-in-plsql-utilizzando-dbms_crypto/]

  • Error while calling XQuery Function with xs:date type as Argument

    Hi,
    I have follwing function in my DataService .
    declare function tns:getXXXDetail($effectiveDate as xs:date,
    $cancelDate as xs:date) as element(ns26:XXXAccount)* {
              implCode
    declare function tns:testGetXXXDetail($searchCriteria as element(ns15:locateMemberXXXDetail))
                   as element(ns26:XXXAccount)* {
    for $Account in tns:getXXXDetail($searchCriteria/ns16:accountTypeDates/ns18:effectiveDate,
         $searchCriteria/ns16:accountTypeDates/ns18:cancelDate)
    return $Account
    I am trying to test the getXXXDetail() function from testGetXXXDetail .
    The searchCriteria is a complex type with date elements effectiveDate and cancelDate, both are optional
    When i test with effectiveDate,cancelDate elements present in $searchCriteria its working fine.
    When i remove these dates element i am getting follwing error
    "expected exactly one item, got 0 items" error
    Any Clue ?

    When i remove these dates element i am getting follwing error"expected exactly one item, got 0 items" error
    Sounds like your schema for these items indicates minOccurs="1" (or relies on that as the default).
    Edit the schema and change the definitions to be...
    <xs:element name="effectiveDate" minOccurs="0" ... />

  • Xquery mapping from Complext type to Array type

    Hi,
    please help to solve this , i will post my source xsd nad target xsd,source has complex type and target xsd has assry type ,i need a direct mapping with elements[one to one mappling]
    pls help me to solve,
    SOURCE XSD
    <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="updateOrderStatus">
    <xs:complexType>
    <xs:sequence>
    <xs:element name="orderStatusUpdate">
    <xs:complexType>
    <xs:sequence>
    <xs:element name="orderDetails">
    <xs:complexType>
    <xs:sequence>
    <xs:element name="lineItems">
    <xs:complexType>
    <xs:sequence>
    <xs:element name="lineItemList">
    <xs:complexType>
    <xs:sequence>
    <xs:element name="item" minOccurs="0" maxOccurs="unbounded">
    <xs:complexType>
    <xs:sequence>
    <xs:element type="xs:string" name="itemStatus"/>
    <xs:element name="shippingDetail">
    <xs:complexType>
    <xs:sequence>
    <xs:element type="xs:int" name="quantity"/>
    <xs:element type="xs:string" name="shipper"/>
    <xs:element type="xs:string" name="trackingNumber"/>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    <xs:element type="xs:string" name="skuId"/>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    <xs:element type="xs:string" name="orderId"/>
    <xs:element type="xs:string" name="orderStatus"/>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    </xs:schema>
    TARAGET XSD
    <schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" targetNamespace="http://www.atg.com/com.nbty.commerce.integration.orderstatusupdate" xmlns:tns="http://www.atg.com/com.nbty.commerce.integration.orderstatusupdate" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
    <complexType name="OrderStatusUpdate">
    <all>
    <element name="orderDetails" nillable="true" type="tns:OrderDetails"/>
    <element name="orderId" nillable="true" type="xsd:string"/>
    <element name="orderStatus" nillable="true" type="xsd:string"/>
    </all>
    </complexType>
    <complexType name="OrderDetails">
    <all>
    <element name="lineItems" nillable="true" type="tns:LineItems"/>
    </all>
    </complexType>
    <complexType name="LineItems">
    <all>
    <element name="lineItemList" nillable="true" type="tns:ArrayOfLineItem"/>
    </all>
    </complexType>
    <complexType name="ArrayOfLineItem">
    <complexContent>
    <restriction base="soap-enc:Array">
    <attribute ref="soap-enc:arrayType" wsdl:arrayType="tns:LineItem[]"/>
    </restriction>
    </complexContent>
    </complexType>
    <complexType name="LineItem">
    <all>
    <element name="itemStatus" nillable="true" type="xsd:string"/>
    <element name="shippingDetail" nillable="true" type="tns:ShippingDetail"/>
    <element name="skuId" nillable="true" type="xsd:string"/>
    </all>
    </complexType>
    <complexType name="ShippingDetail">
    <all>
    <element name="quantity" nillable="true" type="xsd:string"/>
    <element name="shipper" nillable="true" type="xsd:string"/>
    <element name="trackingNumber" nillable="true" type="xsd:string"/>
    </all>
    </complexType>
    </schema>
    regards
    Abhi

    Hi,
    Here's a query that should answer part of the question :
    <student>
      for $i in doc("doc.xml")/student/*
      return
       <field name="{upper-case(name($i))}">
        if ($i/*) then string-join($i/*, ";")
        else $i/text()
       </field>
    </student>It deals with all possible children of the student node. If a child has descendants, then their values are aggregated like you require, else just the child value is used.
    Additional question : where do the default values come from? Do we just have to "paste" the string "default1;default2;default3" as a whole?
    HTH.

  • Extract xsi:type of an element from xquery

    Hi,
    i need to extract the xsi:type of an element in xml.
        <record A="3983" B="3983" xsi:type="listAcct:InventoryItem">
    I know that for attribute we can use @ how do we extract xsi:type?
    Please let me know.
    Thanks

    Hi,
    I know that for attribute we can use @
    What's the problem then?
    The situation is no different, except you also have to declare the namespace prefix (if not already done) :
    declare namespace xsi = "http://www.w3.org/2001/XMLSchema-instance";
    let $e := <record A="3983" B="3983" xsi:type="listAcct:InventoryItem">
    return $e/@xsi:type

  • Oracle 11g - how to disable the Static Type-Checking of XQuery Expressions

    Hi,
    I loaded XML files using pl/sql in Oracle 10 suggesfully and now after upgrading to 11g the thing doesn't work anymore.
    I believe the problem has to do with the DTD, the xml files structure is not as specified in the DTD. I did get away in Oracle 10 issuing the alter session set events ='31156 trace name context forever, level 2' in the code. Now this doesn't seem to have any effect. When loading the xml file I get the following error message
    "ORA-19276 XPST0005 - Xpath step specifies an invalid element/attribute name"
    How can I skip the checking as I can't change the DTD's.
    TIA,
    Kari

    DTD Support in Oracle XML DB
    A DTD is a set of rules that define the allowable structure of an XML document. DTDs are text files that derive their format from SGML and
    can be associated with an XML document either by using the <code>DOCTYPE</code> element or by using an external file through a DOCTYPE
    reference. In addition to supporting XML Schema, which provides a structured mapping to object-relational storage or binary XML storage,
    Oracle XML DB also supports DTD specifications in XML instance documents. Though DTDs are not used to derive the mapping, XML
    processors can still access and interpret the DTDs.
    Inline DTD Definitions
    When an XML instance document has an inline DTD definition, it isused during document parsing. Any DTD validations and entity
    declaration handling is done at this point. However, once parsed, theentity references are replaced with actual values and the original
    entity reference is lost.
    External DTD Definitions
    Oracle XML DB also supports external DTD definitions if they are stored in Oracle XML DB Repository. Applications needing to process an
    XML document containing an external DTD definition such as /public/flights.dtd, must first ensure that the DTD document is stored in Oracle XML DB at path /public/flights.xsd.
    .... thats all I could find...
    http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28369/xdb05sto.htm#sthref540
    Edited by: Marco Gralike on Feb 26, 2009 11:19 AM

  • In ODSI 10gR3 fn:string-length() not pushing down to db (SR: 7714015.993)

    Under ALDSP 2.5, the following XQuery...
    where string-length($medacf) = 0 or $medacf = $acf/column_name
    ...used to generate this SQL:
    where ((? = 0) OR (? = t1."COLUMN_NAME"))
    However, under ODSI 10gR3, the where clause is missing. Here's the query plan:
    <?xml version="1.0"?>
    <FLWOR>
    <return>
    <elementConstructor name="UserGroup" tip="{ld:PhysicalLayer/UserProfile/UserGroup}UserGroup">
    <elementConstructor field="(0)" name="UserID" from="$f7815">
    </elementConstructor>
    <elementConstructor field="(1)" name="GroupID" from="$f7815">
    </elementConstructor>
    </elementConstructor>
    </return>
    <where sqlstop="Unable to generate SQL for XQuery expression: Cannot generate SQL for the function {http://www.bea.com/xquery/xquery-operators}integer-equal with parameters (Parameter,INTEGER), (Constant,INTEGER). There is no equivalent SQL for this function in general or with these particular parameter kinds/types. ">
    <operator ns="op" name="boolean-or" tip="{http://www.w3.org/2004/07/xpath-operators}boolean-or">
    <EQ sqlstop="Cannot generate SQL for the function {http://www.bea.com/xquery/xquery-operators}integer-equal with parameters (Parameter,INTEGER), (Constant,INTEGER). There is no equivalent SQL for this function in general or with these particular parameter kinds/types. " tip="{http://www.bea.com/xquery/xquery-operators}integer-equal">
    <operator ns="fn" name="string-length" tip="{http://www.w3.org/2004/07/xpath-functions}string-length">
    <variable name="__fparam0" kind="EXTERNAL">
    </variable>
    </operator>
    <constant>
    <![CDATA[[integer 0]]]>
    </constant>
    </EQ>
    <EQ tip="{http://www.bea.com/xquery/xquery-operators}string-equal">
    <variable name="__fparam0" kind="EXTERNAL">
    </variable>
    <variable name="(2)" from="$f7815" kind="extracted">
    </variable>
    </EQ>
    </operator>
    </where>
    <for name="$f7815">
    <source ns="fn-bea" name="UsrProfDataSource" sqlwarning="Generated SQL query does not have a WHERE clause. This may cause the query to take longer to finish and use excessive memory resources." kind="relational" tip="UsrProfDataSource">
    <![CDATA[SELECT UPPER(t1."USER_ID") AS c1, t1."GRP_ID" AS c2, t1."USER_ID" AS c3
    FROM "USRPROF"."USER_GRP" t1]]>
    </source>
    </for>
    </FLWOR>

    We have found that in ODSI 10gR3, the code pattern below is not pushed down if $logicalExpression is an expression that compares two atomic values and one of the values is a constant (used to work in ALDSP 2.5):
    where $logicalExpression or $table/column = $input
    Sample code that is not pushed down as expected:
    where fn:string-length($accountNumber) _<= 0_ or $account/ACCT_NUM = $accountNumber
    where fn:empty($accountNumber) or $accountNumber _= ''_ or $account/ACCT_NUM = $accountNumber
    where fn:empty($clientId) or $clientId _= 0_ or $account/CLIENT_ID = $clientId
    where fn:empty($effectiveDate) or $effectiveDate _= xs:date('0001-01-01')_ or $account/ACCT_EFF_DT = $effectiveDate
    We have also found that a workaround is to tweak the code and replace $logicalExpression with something that can be pushed down and functionally equivalent (using fn:not, fn-bea:fence, fn:exactly-one, etc.).
    Code that works:
    where fn:not(fn:string-length($accountNumber) > 0) or $account/ACCT_NUM = $accountNumber
    where fn-bea:fence(fn:string-length($accountNumber) <= 0) or $account/ACCT_NUM = $accountNumber
    where fn:exactly-one(fn:string-length($accountNumber) <= 0) or $account/ACCT_NUM = $accountNumber
    After examining the query plans, it appears to me (please correct me if any of these is not true):
    - Comparators for atomic types ({http://www.bea.com/xquery/xquery-operators} integer-less-than-or-equal, string-equal, date-equal, etc.) are not pushed down if they are used to compare anything with a constant
    - An "or" operation ({http://www.w3.org/2004/07/xpath-operators} boolean-or) is not pushed down if any of its operands cannot be pushed down
    - fn:not, fn-bea:fence, and fn:exactly-one can be pushed down even if their operand cannot be pushed down
    So the question is, why comparators are not pushed down when constants are involved? Is this a bug?
    Thanks!
    -r.

Maybe you are looking for