Xquery evaluation

I'm trying to execute the xquery function 'GuidsReferencingTo' (code is below) and getting this error ''Error: It is an error for the context item to be undefined when using it [err:XPDY0002], <query>:42:58'. The error happens in the function 'GuidChildren' that is called from "where" block (via SelfAndDerivedGuids and DerivedGuids functions). First I would expect ‘let’ clause to be evaluated before, but it looks like it's being evaluated in ‘where’ clause (does it happens in each loop?). Second, it looks like somewhere empty sequence causes this issue somehow. Disabling both 'some' clauses eliminates the issue.
There no problems when 'GuidChildren', ‘DerivedGuids’ or ‘SelfAndDerivedGuids’ are not involved into ‘some’ clause (they used in many places).
declare function pg:SelectByID ( $id as xs:string )
let $t := dbxml:lookup-attribute-index ( "D:/Projects/adb/xml_data/data.dbxml", "pg:id" )[.=$id]/parent::*
(:let $t := collection ( "dbxml:/D:/Projects/adb/xml_data/data.dbxml" )//pg:*[@pg:id=$id]:)
     return
     if ( fn:empty ( $t ) )
then pg:SelectByID ( '00000000000000000000000000000000' )
else $t
declare function pg:Self ( $id as xs:string )
let $r := pg:SelectByID ( $id )
return
if ( $r/@pg:type = "00000000000000000000000000000007" )
then pg:SelectByID ( $r/@pg:parent cast as xs:string )
else $r
declare function pg:GuidChildren ( $id as xs:string )
(:dbxml:lookup-attribute-index ( 'c:/adb/data/data.dbxml', 'pg:parent' )[.=$id]/parent::*:)
collection ( "dbxml:/c:/adb/data/data.dbxml" )//pg:*[@pg:parent=$id]
declare function pg:DerivedGuids ( $id as xs:string )
for $t in pg:GuidChildren ( $id )
return ( $t, pg:DerivedGuids ( $t/@pg:id cast as xs:string ) )
declare function pg:SelfAndDerivedGuids ( $id as xs:string )
let $t := pg:Self ( $id )
return
if ( $t/@pg:id != '00000000000000000000000000000000' )
then ( $t, pg:DerivedGuids ( $t/@pg:id cast as xs:string ) )
else $t
declare function pg:GuidsReferencingTo ( $type as xs:string, $attrRef as xs:string, $attrType as xs:string )
let $t := pg:SelfAndDerivedGuids ( $type )
let $rt := pg:SelfAndDerivedGuids ( $attrType )
for $r in dbxml:lookup-attribute-index ( 'c:/adb/data/data.dbxml', 'pg:ref' )[.=$attrRef]/parent::pg:r
where
( some $n in $rt satisfies $r/@pg:rt = $n/@pg:id ) and
( some $m in $t satisfies $r/parent::*/@pg:type = $m/@pg:id )
return $r/parent::*
};

formatted code
declare function pg:SelectByID ( $id as xs:string )
    let $t := dbxml:lookup-attribute-index ( "D:/Projects/adb/xml_data/data.dbxml", "pg:id" )[.=$id]/parent::*
    (:let $t := collection ( "dbxml:/D:/Projects/adb/xml_data/data.dbxml" )//pg:*[@pg:id=$id]:)
     return
         if ( fn:empty ( $t ) )
            then pg:SelectByID ( '00000000000000000000000000000000' )
            else $t
declare function pg:Self ( $id as xs:string )
    let $r := pg:SelectByID ( $id )
    return
        if ( $r/@pg:type = "00000000000000000000000000000007" )
            then pg:SelectByID ( $r/@pg:parent cast as xs:string )
            else $r
declare function pg:GuidChildren ( $id as xs:string )
    (:dbxml:lookup-attribute-index ( 'c:/adb/data/data.dbxml', 'pg:parent' )[.=$id]/parent::*:)
    collection ( "dbxml:/c:/adb/data/data.dbxml" )//pg:*[@pg:parent=$id]
declare function pg:DerivedGuids ( $id as xs:string )
    for $t in pg:GuidChildren ( $id )
    return ( $t, pg:DerivedGuids ( $t/@pg:id cast as xs:string ) )
declare function pg:SelfAndDerivedGuids ( $id as xs:string )
    let $t := pg:Self ( $id )
    return
        if ( $t/@pg:id != '00000000000000000000000000000000' )
            then ( $t, pg:DerivedGuids ( $t/@pg:id cast as xs:string ) )
            else $t
declare function pg:GuidsReferencingTo ( $type as xs:string, $attrRef as xs:string, $attrType as xs:string )
    let $t := pg:SelfAndDerivedGuids ( $type )
    let $rt := pg:SelfAndDerivedGuids ( $attrType )
    for $r in dbxml:lookup-attribute-index ( 'c:/adb/data/data.dbxml', 'pg:ref' )[.=$attrRef]/parent::pg:r
        where
            ( some $n in $rt satisfies $r/@pg:rt = $n/@pg:id ) and
            ( some $m in $t satisfies $r/parent::*/@pg:type = $m/@pg:id )
        return $r/parent::*
};

Similar Messages

  • CDATA and XML structure

    Hej!
    I am trying to but an entire XML structure into a CDATA-tag. But have not been successful.
    Im using Xquery and trying to somthing like this:
    I have an variable $example which contains a XML structure. For example:
    $example = <elementA><A1>valueA1</A1><A2><A2a>text2a</A2a><A2b>text2b</A2b></A2><A3>valueA3</A3></elementA>
    I want to something like this <![CDATA[$example]]> to be expanded to <![CDATA[<elementA><A1>valueA1</A1><A2><A2a>text2a</A2a><A2b>text2b</A2b></A2><A3>valueA3</A3></elementA>]]>
    I have tried in many ways (eg by doing concat("<![CDATA[", $example, "]]>") ) and ended up with a CDATA tag that contains only the value of the elements in the tags of A1, A2 and A3. for example the CDATA that is created looks something like this:
    <![CDATA[valueA1text2atext2bvalueA3]]>
    instead of
    <![CDATA[<elementA><A1>valueA1</A1><A2><A2a>text2a</A2a><A2b>text2b</A2b></A2><A3>valueA3</A3</elementA>]]>
    I would really be grateful for any suggestions or tips and pointers on how to solve this.
    Best Regards
    Ninib
    Edited by: NinibEDB on 2010-nov-09 17:35

    Hi,
    Which XQuery processor are you using?
    According to the W3C specifications, the output of CDATA section is part of the serialization process, not the XQuery evaluation. So it's up to the implementor to provide the necessary options.
    The option we need here is the "cdata-section-elements" parameter :
    http://www.w3.org/TR/xslt-xquery-serialization/#XML_CDATA-SECTION-ELEMENTS
    For example, using the Saxon XQuery processor :
    declare option saxon:output "omit-xml-declaration=yes";
    declare option saxon:output "cdata-section-elements=test";
    let $example := "<elementA><A1>valueA1</A1><A2><A2a>text2a</A2a><A2b>text2b</A2b></A2><A3>valueA3</A3></elementA>"
    return <test>{$example}</test>which gives :
    <test><![CDATA[<elementA><A1>valueA1</A1><A2><A2a>text2a</A2a><A2b>text2b</A2b></A2><A3>valueA3</A3></elementA>]]></test>

  • Remove string duplicates

    Hello,
    I need help in removing duplicates from a string that contains years and "-". Example: 1988-1997-2000-2013-1998-1965-1997-1899
    I know this can be done in regular expressions but have no experience in this subject.
    select REGEXP_REPLACE(.....) from dual;
    Thank you

    odie_63 wrote:
    For "large" strings, XQuery evaluation happens to be faster
    But model solution beats them both and also preserves the order:
    set timing on
    set serveroutput on
    declare
        v_result varchar2(4000);
        v_list   varchar2(4000) := '1988-1997-2000-2013-1998-1965-1997-1899-1997-2000-2013-1998-1965-1997-1899-1997-2000-2013-1998-1965-1997-1899';
    begin
        for i in 1 .. 50000 loop
          select  /*+ no_xmlquery_rewrite */
                 xmlcast(
                         xmlquery(
                                  'string-join(distinct-values(ora:tokenize($list, "-")[.]), "-")'
                                  passing v_list || '-' as "list"
                                  returning content
                         as varchar2(4000)
            into  v_result
            from  dual;
        end loop;
        dbms_output.put_line(v_result);
    end;
    1899-1965-1988-1997-1998-2000-2013
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:15.31
    declare
        v_result varchar2(4000);
        v_list   varchar2(4000) := '1988-1997-2000-2013-1998-1965-1997-1899-1997-2000-2013-1998-1965-1997-1899-1997-2000-2013-1998-1965-1997-1899';
    begin
        for i in 1 .. 50000 loop
          select  listagg(str, '-') within group (order by null)
            into  v_result
            from  (
                   select  distinct regexp_substr(v_list, '[^-]+', 1, level) str
                     from  dual
                     connect by level <= regexp_count(v_list, '-') + 1
        end loop;
        dbms_output.put_line(v_result);
    end;
    1899-1965-1988-1997-1998-2000-2013
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:26.06
    declare
        v_result varchar2(4000);
        v_list   varchar2(4000) := '1988-1997-2000-2013-1998-1965-1997-1899-1997-2000-2013-1998-1965-1997-1899-1997-2000-2013-1998-1965-1997-1899';
    begin
        for i in 1 .. 50000 loop
          select  ltrim(newstr,'-')
            into  v_result
            from  dual
            model
              dimension by(0 d)
              measures(
                       '-' || replace(v_list,'-','--') || '-' workarea,
                       cast(null as varchar2(4000)) element,
                       cast(null as varchar2(4000)) newstr
              rules iterate(1e6) until(workarea[0] is null)
                 element[0]  = substr(workarea[0],1,instr(workarea[0],'-',2)),
                 newstr[0]   = newstr[0] || rtrim(element[0],'-'),
                 workarea[0] = replace(workarea[0],element[0])
        end loop;
        dbms_output.put_line(v_result);
    end;
    1988-1997-2000-2013-1998-1965-1899
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:11.94
    SQL>
    SY.

  • XQuery with recuesive function and instance of operation gives problem

    Hi,
    << Using Oracle 11g .06. release >>
    I have an Xquery that has recursive functions and "instance of" operation.
    I facing the following problem
    "error raised during evaluation: oracle.xquery.XQException: XPTY0004: It is a type error if, during the static analysis phase, an expression is found to have a static type that is not appropriate for the context in which the expression occurs, or during the dynamic evaluation phase, the dynamic type of a value does not match a required type as specified by the matching rules in 2.5.4 SequenceType Matching.
    Detail: empty sequence encountered where a sequence of length one is expected
    The same xQuery works on Berkely DB, Altova XML and Oxygen. I could able to figure out the problem in oracle, where i need an help from you people.
    The below is the XQuery Function
    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    SELECT XMLQuery('xquery version "1.0";
    declare default element namespace "WiMax_CAPC_XML";(: :)
    declare namespace HHP="HHP";(: :)
    declare namespace AtomicXQuery="AtomicXQuery";(: :)
    declare function AtomicXQuery:filter-modifier($element as element(), $attribute-name as xs:string*) {
    element {node-name($element)}
    for $child in $element/node()
    return if ($child instance of element())
    then (("deepa instance"),$child,"45",name($child),$attribute-name,
    if($child/node() instance of element())
    then ("it is an instance of element")
    else($child),
    AtomicXQuery:filter-modifier($child, $attribute-name))
    else $child
    let $i:= ora:view("NECB")/node()/child::*[2]/HHP:HHP/HHP:hapNe/HHP:maxCageCount
    let $m:=element HHP:deepa {element HHP:deepa1 {"deepa1"}} return AtomicXQuery:filter-modifier($m,"modifier")'
    RETURNING CONTENT) AS RESULT
    FROM DUAL;
    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    The XML data is available in XMLType table NECB.
    The XMLData is as follows
    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    <?xml version="1.0" encoding="UTF-8"?>
    <ConfigDataFile xmlns="WiMax_CAPC_XML" xmlns:HHP="HHP" xmlns:SWM="SWM" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <fileHeader cfgMinorVersion="0" cfgSavedMinorVersion="0" cfgVersion="0" fileFormatVersion="CAPC_I1" fileName="NECB.xml" fileType="necb" senderName="CNEOMI" swVersion="D00.00.01.05" vendorName="Motorola"/>
    <configData dnPrefix="String">
    <HHP:HHP>
    <HHP:hapNe>
    <HHP:maxCageCount>3</HHP:maxCageCount>
    <HHP:minLogLevel>1</HHP:minLogLevel>
    </HHP:hapNe>
    <HHP:hapCageTable>
    <HHP:hapCageEntry cageId="1">
    <HHP:numOfModems>1</HHP:numOfModems>
    <HHP:numOfBackupModems>1</HHP:numOfBackupModems>
    <HHP:hapCagemaxModemCount>1</HHP:hapCagemaxModemCount>
    <HHP:minModemLogLevel>1</HHP:minModemLogLevel>
    <HHP:hapModemTable>
    <HHP:hapModemEntry cageId="1" modemId="1">
    <HHP:maxServiceTypeCount>1</HHP:maxServiceTypeCount>
    <HHP:hapModemLogLevel>1</HHP:hapModemLogLevel>
    <HHP:maxBlackboxCount>1</HHP:maxBlackboxCount>
    <HHP:minBlackboxLogLevel>1</HHP:minBlackboxLogLevel>
    <HHP:hapBlackboxTable>
    <HHP:hapBlackboxEntry cageId="1" modemId="1" blackboxId="1">
    <HHP:hapBlackboxLogLevel>1</HHP:hapBlackboxLogLevel>
    </HHP:hapBlackboxEntry>
    </HHP:hapBlackboxTable>
    </HHP:hapModemEntry>
    </HHP:hapModemTable>
    </HHP:hapCageEntry>
    </HHP:hapCageTable>
    <HHP:serviceTypeTable>
    <HHP:serviceTypeEntry serviceTypeId="1">
    <HHP:priority>1</HHP:priority>
    <HHP:serviceTypemaxModemCount>1</HHP:serviceTypemaxModemCount>
    </HHP:serviceTypeEntry>
    </HHP:serviceTypeTable>
    <HHP:serviceMappingTable>
    <HHP:serviceMappingEntry cageId="1" modemId="1" serviceTypeId="1">
    </HHP:serviceMappingEntry>
    </HHP:serviceMappingTable>
    </HHP:HHP>
         <SWM:SWM>
    <SWM:wmanIfBsPagingGroupTable>
    <SWM:wmanIfBsPagingGroupEntry ifIndex="1" wmanIfBsPagingGroupIndex="1">
    <SWM:wmanIfBsPagingGroupId>1</SWM:wmanIfBsPagingGroupId>
    <SWM:wmanIfBsPagingControllerId>9</SWM:wmanIfBsPagingControllerId>
    <SWM:wmanIfBsPagingCycle>100</SWM:wmanIfBsPagingCycle>
    <SWM:wmanIfBsPagingOffset>1</SWM:wmanIfBsPagingOffset>
    <SWM:wmanIfBsPagingRetryCount>3</SWM:wmanIfBsPagingRetryCount>
    <SWM:wmanIfBsPagingBcastRetryCount>3</SWM:wmanIfBsPagingBcastRetryCount>
    <SWM:wmanIfBsPagingControllerAddress>aabbccddeeffaabbccddeeffaabbccddeeffaabbccddeeffaabbccddeeffaabb</SWM:wmanIfBsPagingControllerAddress>
    <SWM:wmanIfBsPagingControllerAddressType>1</SWM:wmanIfBsPagingControllerAddressType>
    <SWM:wmanIfBsPagingControllerAsnMmId>aabbccddeeff</SWM:wmanIfBsPagingControllerAsnMmId>
    </SWM:wmanIfBsPagingGroupEntry>
    </SWM:wmanIfBsPagingGroupTable>
    <SWM:wmanIfAsnMmTable>
    <SWM:wmanIfAsnMmEntry ifIndex="1">
    <SWM:wmanIfAsnMmId>AAffFFAAAAFF</SWM:wmanIfAsnMmId>
    <SWM:wmanIfAsnMmId/>
    </SWM:wmanIfAsnMmEntry>
    </SWM:wmanIfAsnMmTable>
    <SWM:wmanIfNeighborAsnMmTable>
    <SWM:wmanIfNeighborAsnMmEntry ifIndex="1" wmanIfNbrAsnMmId="AAffFFAAAAFFFFFF">
    <SWM:wmanIfNbrAsnMmAddress>AAffFFAAAAFFFFFF</SWM:wmanIfNbrAsnMmAddress>
    <SWM:wmanIfNbrAsnMmAddressType>1</SWM:wmanIfNbrAsnMmAddressType>
    <SWM:wmanIfNbrAsnMmControlSecurityProtocol>1</SWM:wmanIfNbrAsnMmControlSecurityProtocol>
    </SWM:wmanIfNeighborAsnMmEntry>
    </SWM:wmanIfNeighborAsnMmTable>
    </SWM:SWM>
    </configData>
    <fileFooter dateTime="2007-11-07T09:30:47.0Z" update="2007-11-07T09:30:47.0Z"/>
    </ConfigDataFile>
    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    The expected output XML is as follows
    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    <HHP:deepa xmlns="WiMax_CAPC_XML" xmlns:HHP="HHP">deepa instance<HHP:deepa1>deepa1</HHP:deepa1>45 HHP:deepa1 modifier<HHP:deepa1>deepa1</HHP:deepa1>
         <HHP:deepa1>deepa1</HHP:deepa1>
    </HHP:deepa>
    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    Thanks in advance!

    Ashwin,
    Please try it with 11.1.0.7 instead and let us know if it works.
    Regards,
    Geoff

  • Xquery function in pl sql

    Hi all.
    Is some body know can XQuery functions be used/declared in pl sql? More deep, can I cover XQuery function by pl sql function or procedure? And how to input parameters/variables to Xquery function from pl sql?
    Any links to manual will be helpful.
    Best regards,
    Anton.

    Something like that?:
    SQL> create or replace procedure index_scan (index_name varchar2, name varchar2)
    as
       xml   xmltype;
    begin
       select xmlquery (
    if ("article-by-title" = $index_name) then doc("/wiki")/root/page[title=$name]
    else if ("article-by-id" = $index_name) then doc("/wiki")/root/page[id=$name]
    else if ("link-by-target" = $index_name) then doc("/wiki")/root/page/links/link[@target = $name]
    else if ("article-by-cat" = $index_name) then doc("/wiki")/root/page/catlinks/catlink[@target=$name]
    else error(fn:QName("http://www.w3.org/2005/xqt-errors",  $index_name) , "Some error occured") '
                 passing index_name as "index_name", name as "name"
                 returning content)
         into xml
         from dual;
    end index_scan;
    Procedure created.
    SQL> exec index_scan('My Index Name','My Name')
    BEGIN index_scan('My Index Name','My Name'); END;
    Error at line 20
    ORA-19112: error raised during evaluation: :My Index Name
    Detail: Some error occured
    ORA-06512: at "MICHAEL.INDEX_SCAN", line 5
    ORA-06512: at line 1Don't have your resources - therefore the error!

  • 10g vs 11g xquery performance with XBRL

    Finally,I set up 11g on small notebook with 1G memory.
    The result was impresive compared to 10g ,but I need more than that.
    I used this query generating 761 rows for testing
    SELECT c.seqno,xt.ns,xt.name,nvl(xt.lang,'na') as lang,xt.unit,xt.decimals,
    xt.value
    FROM FINES_CTX c,FINES_XBRL_CLOB r,
    XMLTABLE(
    XMLNAMESPACES(
    'http://www.xbrl.org/2003/linkbase' AS "link",
    'http://www.w3.org/1999/xlink' AS "xlink",
    'http://www.w3.org/2001/XMLSchema' AS "xsd",
    'http://www.xbrl.org/2003/instance' AS "xbrli",
    'http://fss.xbrl.or.kr/kr/br/f/aa/2007-06-30' AS
    "fines-f-aa",
    'http://fss.xbrl.or.kr/kr/br/b/aa/2007-06-30' AS
    "fines-b-aa",
    'http://fss.xbrl.or.kr/kr/br/f/ad/2007-06-30' AS
    "fines-f-ad",
    'http://fss.xbrl.or.kr/kr/br/b/ad/2007-06-30' AS
    "fines-b-ad",
    'http://fss.xbrl.or.kr/kr/br/f/af/2007-06-30' AS
    "fines-f-af",
    'http://fss.xbrl.or.kr/kr/br/b/af/2007-06-30' AS
    "fines-b-af",
    'http://fss.xbrl.or.kr/kr/br/f/ai/2007-06-30' AS
    "fines-f-ai",
    'http://fss.xbrl.or.kr/kr/br/b/ai/2007-06-30' AS
    "fines-b-ai",
    'http://fss.xbrl.or.kr/kr/br/f/ak/2007-06-30' AS
    "fines-f-ak",
    'http://fss.xbrl.or.kr/kr/br/b/ak/2007-06-30' AS
    "fines-b-ak",
    'http://fss.xbrl.or.kr/kr/br/f/bs/2007-06-30' AS
    "fines-f-bs",
    'http://fss.xbrl.or.kr/kr/br/b/bs/2007-06-30' AS
    "fines-b-bs",
    'http://xbrl.org/2005/xbrldt' AS "xbrldt",
    'http://www.xbrl.org/2004/ref' AS "ref",
    'http://www.xbrl.org/2003/XLink' AS "xl"),
    for $item in $doc/xbrli:xbrl/*[not(starts-with(name(),"xbrli:")) and not(starts-with(name(),"link:"))]
    where $item/@contextRef
    return <item decimals="{$item/@decimals}" contextRef="{$item/@contextRef}" xml:lang="{$item/@xml:lang}" unitRef="{$item/@unitRef}" name="{local-name($item)}" ns="{namespace-uri($item)}">{$item/text()}</item>'
    PASSING r.xbrl as "doc"
    COLUMNS context_id varchar2(128) PATH '@contextRef',
    ns varchar2(128) PATH '@ns',
    name varchar2(128) PATH '@name',
    lang varchar2(2) PATH '@xml:lang',
    unit varchar2(16) PATH '@unitRef',
    decimals varchar2(64) PATH '@decimals',
    value varchar(256) PATH '.'
    ) xt
    WHERE c.report_cd = r.report_cd and c.finance_cd = r.finance_cd and
    c.base_month = r.base_month and c.gubn_cd = r.gubn_cd
    and c.seqno = 109299 and c.context_id = xt.context_id
    all the tables have 500 rows and non-schema-based xmltype clolumn.
    FINES_XBRL_CLOB - xmltype stored as clob
    FINES_XBRL_BINARY - xmltype stored as binary with xml index
    FINES_XBRL_BINARY_NI - xmltype stored as binary without xml index.
    case 1 : run on 10g with XMLType stored as CLOB
    time: took 1270 secs.- quite disappointed.
    plan: 0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=26 Card=82 Bytes=173K)
    1 0 NESTED LOOPS (Cost=26 Card=82 Bytes=173K)
    2 1 NESTED LOOPS (Cost=2 Card=1 Bytes=2K)
    3 2 TABLE ACCESS (BY INDEX ROWID) OF 'FINES_CTXB' (TABLE) (Cost=1 Card=1 Bytes=119)
    4 3 INDEX (UNIQUE SCAN) OF 'PK_FINES_CTXB' (INDEX (UNIQUE)) (Cost=1 Card=1)
    5 2 TABLE ACCESS (BY INDEX ROWID) OF 'FINES_XBRLB' (TABLE) (Cost=1 Card=82 Bytes=164K)
    6 5 INDEX (UNIQUE SCAN) OF 'PK_FINES_XBRLB' (INDEX (UNIQUE)) (Cost=0 Card=1)
    7 1 COLLECTION ITERATOR (PICKLER FETCH) OF 'SYS.XQSEQUENCEFROMXMLTYPE' (PROCEDURE)
    case 2: run on 11g with XMLType stored as CLOB
    time: took 27 secs. - almost 50 times faster
    plan:
    0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=114 Card=1 Bytes=2K)
    1 0 FILTER
    2 1 NESTED LOOPS (Cost=32 Card=82 Bytes=173K)
    3 2 NESTED LOOPS (Cost=3 Card=1 Bytes=2K)
    4 3 TABLE ACCESS (BY INDEX ROWID) OF 'FINES_CTX' (TABLE) (Cost=2 Card=1 Bytes=119)
    5 4 INDEX (UNIQUE SCAN) OF 'PK_FINES_CTX' (INDEX (UNIQUE)) (Cost=1 Card=1)
    6 3 TABLE ACCESS (BY INDEX ROWID) OF 'FINES_XBRL_CLOB' (TABLE) (Cost=1 Card=5K Bytes=10M)
    7 6 INDEX (UNIQUE SCAN) OF 'PK_FINES_XBRL_CLOB' (INDEX (UNIQUE)) (Cost=0 Card=1)
    8 2 COLLECTION ITERATOR (PICKLER FETCH) OF 'SYS.XMLSEQUENCEFROMXMLTYPE' (PROCEDURE)
    9 1 COLLECTION ITERATOR (PICKLER FETCH) OF 'SYS.XQSEQUENCEFROMXMLTYPE' (PROCEDURE)
    case 3: run on 11g with XMLType stored as BINARY no XMLIndex
    time: 10 secs (9.6 sec exactly) , 120 times faster..
    0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=113 Card=1 Bytes=2K)
    1 0 FILTER
    2 1 NESTED LOOPS (Cost=33 Card=80 Bytes=169K)
    3 2 NESTED LOOPS (Cost=3 Card=1 Bytes=2K)
    4 3 TABLE ACCESS (BY INDEX ROWID) OF 'FINES_CTX' (TABLE) (Cost=2 Card=1 Bytes=119)
    5 4 INDEX (UNIQUE SCAN) OF 'PK_FINES_CTX' (INDEX (UNIQUE)) (Cost=1 Card=1)
    6 3 TABLE ACCESS (BY INDEX ROWID) OF 'FINES_XBRL_BINARY_NI' (TABLE) (Cost=1 Card=82 Bytes=164K)
    7 6 INDEX (UNIQUE SCAN) OF 'PK_FINES_BINARY_XBRL_NI' (INDEX (UNIQUE)) (Cost=0 Card=1)
    8 2 XPATH EVALUATION
    9 1 XPATH EVALUATION
    CREATE INDEX fines_xbrl_binary_ix ON fines_xbrl_binary (xbrl) INDEXTYPE IS XDB.XMLIndex
    case 4: run on 11g with XMLType stored as BINARY and XMLIndex
    time: 574 secs. - oops...not good.
    plan: quite long..
    0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=16 Card=1 Bytes=5K)
    1 0 FILTER
    2 1 NESTED LOOPS
    3 2 NESTED LOOPS (Cost=4 Card=1 Bytes=4K)
    4 3 TABLE ACCESS (BY INDEX ROWID) OF 'XDB.X$PT1MP1MWL3978FCE0G24J0CM85AM' (TABLE) (Cost=0 Card=1 Bytes=1008)
    5 4 INDEX (RANGE SCAN) OF 'XDB.X$PR1MP1MWL3978FCE0G24J0CM85AM' (INDEX (UNIQUE)) (Cost=0 Card=1)
    6 3 INDEX (RANGE SCAN) OF 'SYS69876_FINES_XBRL_PATHID_IX' (INDEX) (Cost=2 Card=3)
    7 2 TABLE ACCESS (BY INDEX ROWID) OF 'SYS69876_FINES_XBRL_PATH_TABLE' (TABLE) (Cost=4 Card=1 Bytes=3K)
    8 0 FILTER
    9 8 NESTED LOOPS
    10 9 NESTED LOOPS (Cost=4 Card=1 Bytes=4K)
    11 10 TABLE ACCESS (BY INDEX ROWID) OF 'XDB.X$PT1MP1MWL3978FCE0G24J0CM85AM' (TABLE) (Cost=0 Card=1 Bytes=1008)
    12 11 INDEX (RANGE SCAN) OF 'XDB.X$PR1MP1MWL3978FCE0G24J0CM85AM' (INDEX (UNIQUE)) (Cost=0 Card=1)
    13 10 INDEX (RANGE SCAN) OF 'SYS69876_FINES_XBRL_PATHID_IX' (INDEX) (Cost=2 Card=3)
    14 9 TABLE ACCESS (BY INDEX ROWID) OF 'SYS69876_FINES_XBRL_PATH_TABLE' (TABLE) (Cost=4 Card=1 Bytes=3K)
    15 0 FILTER
    16 15 NESTED LOOPS
    17 16 NESTED LOOPS (Cost=4 Card=1 Bytes=4K)
    18 17 TABLE ACCESS (BY INDEX ROWID) OF 'XDB.X$PT1MP1MWL3978FCE0G24J0CM85AM' (TABLE) (Cost=0 Card=1 Bytes=1008)
    19 18 INDEX (RANGE SCAN) OF 'XDB.X$PR1MP1MWL3978FCE0G24J0CM85AM' (INDEX (UNIQUE)) (Cost=0 Card=1)
    20 17 INDEX (RANGE SCAN) OF 'SYS69876_FINES_XBRL_PATHID_IX' (INDEX) (Cost=2 Card=3)
    21 16 TABLE ACCESS (BY INDEX ROWID) OF 'SYS69876_FINES_XBRL_PATH_TABLE' (TABLE) (Cost=4 Card=1 Bytes=3K)
    22 0 FILTER
    23 22 NESTED LOOPS
    24 23 NESTED LOOPS (Cost=4 Card=1 Bytes=4K)
    25 24 TABLE ACCESS (BY INDEX ROWID) OF 'XDB.X$PT1MP1MWL3978FCE0G24J0CM85AM' (TABLE) (Cost=0 Card=1 Bytes=1008)
    26 25 INDEX (RANGE SCAN) OF 'XDB.X$PR1MP1MWL3978FCE0G24J0CM85AM' (INDEX (UNIQUE)) (Cost=0 Card=1)
    27 24 INDEX (RANGE SCAN) OF 'SYS69876_FINES_XBRL_PATHID_IX' (INDEX) (Cost=2 Card=3)
    28 23 TABLE ACCESS (BY INDEX ROWID) OF 'SYS69876_FINES_XBRL_PATH_TABLE' (TABLE) (Cost=4 Card=1 Bytes=3K)
    29 0 SORT (AGGREGATE) (Card=1 Bytes=3K)
    30 29 FILTER
    31 30 TABLE ACCESS (BY INDEX ROWID) OF 'SYS69876_FINES_XBRL_PATH_TABLE' (TABLE) (Cost=5 Card=32 Bytes=110K)
    32 31 INDEX (RANGE SCAN) OF 'SYS69876_FINES_XBRL_ORDKEY_IX' (INDEX) (Cost=3 Card=92)
    33 0 FILTER
    34 33 NESTED LOOPS
    35 34 NESTED LOOPS (Cost=4 Card=1 Bytes=4K)
    36 35 TABLE ACCESS (BY INDEX ROWID) OF 'XDB.X$PT1MP1MWL3978FCE0G24J0CM85AM' (TABLE) (Cost=0 Card=1 Bytes=1008)
    37 36 INDEX (RANGE SCAN) OF 'XDB.X$PR1MP1MWL3978FCE0G24J0CM85AM' (INDEX (UNIQUE)) (Cost=0 Card=1)
    38 35 INDEX (RANGE SCAN) OF 'SYS69876_FINES_XBRL_PATHID_IX' (INDEX) (Cost=2 Card=3)
    39 34 TABLE ACCESS (BY INDEX ROWID) OF 'SYS69876_FINES_XBRL_PATH_TABLE' (TABLE) (Cost=4 Card=1 Bytes=3K)
    40 0 FILTER
    41 40 NESTED LOOPS
    42 41 NESTED LOOPS (Cost=4 Card=1 Bytes=4K)
    43 42 TABLE ACCESS (BY INDEX ROWID) OF 'XDB.X$PT1MP1MWL3978FCE0G24J0CM85AM' (TABLE) (Cost=0 Card=1 Bytes=1008)
    44 43 INDEX (RANGE SCAN) OF 'XDB.X$PR1MP1MWL3978FCE0G24J0CM85AM' (INDEX (UNIQUE)) (Cost=0 Card=1)
    45 42 INDEX (RANGE SCAN) OF 'SYS69876_FINES_XBRL_PATHID_IX' (INDEX) (Cost=2 Card=3)
    46 41 TABLE ACCESS (BY INDEX ROWID) OF 'SYS69876_FINES_XBRL_PATH_TABLE' (TABLE) (Cost=4 Card=1 Bytes=3K)
    -- continue....
    With very limited test case, I personally concluded that oracle 11g's engine related XML is much better than 10g, especially when using Binary type ,getting additional performance boost.
    xbrl document is basically flat ,not heirarchical structured, that makes XMLIndex inefficient ,I guess.
    Is there any good way to use XMLIndex more efficient just with this kind of case ?
    Please point out anything I can do more.
    thanks.

    I guess you meant to say / instead of "...oracle 11g's engine related XML is much better than 10g..." - "oracle 11g's XQuery engine related XML is much better than 10g"...
    Did you create the XMLIndex as described (case 4)...
    CREATE INDEX fines_xbrl_binary_ix ON fines_xbrl_binary (xbrl) INDEXTYPE IS XDB.XMLIndexIn different words, you didn't use "path subsetting" (http://www.liberidu.com/blog/?p=242) ?
    I guess you created statistics ?
    Thanks for sharing !!!

  • XQuery Modify cannot be compiled

    Hi Gurus. Oracle EE 11.2 running on Linux. SQL Dev 3.2.30.09.
    I am fairly decent with XPath and XSLT but am new to XQuery. I've implemented a few simple FLOWRs but I am getting a bit more complex. I have an XQuery where I am trying to replace some data inline. I have pared the actual XML and the code down to a very simple example that still returns the same error.
    The error:
    ORA-19112: error raised during evaluation: XQuery Update connot be compiled
    19112. 00000 -  "error raised during evaluation: %s"
    *Cause:    The error function was called during evaluation of the XQuery expression.
    *Action:   Check the detailed error message for the possible causes.
    Error at Line: 7 Column: 14
    My Xquery:
    SELECT XMLQuery(
      'copy $tmp := $xmldata
           modify (replace value of node $tmp/MSG_CNTNT_XML/Message/msgHdr/Source/Format/text() with "abc")
         return $tmp'
         PASSING msg_cntnt_xml as "xmldata"
         RETURNING CONTENT ) xmlmct
    FROM (SELECT xmltype('<Message>
       <msgHdr>
          <Source>
             <Format>CTS</Format>
          </Source>
       </msgHdr>
    </Message>') msg_cntnt_xml
           FROM DUAL)
    Any general tips for XQuery and modify is cool but what I am really looking for is why am I getting the "Update connot be compiled". (BTW, notice the spelling error, connot - I'm not judging).
    Any tips for debugging or being able to display intermediate results would be awesome also.
    Thanks.
    LewisC

    Hi Lewis,
    What's your exact database version?
    You're trying to use XQuery Update Facility (a small extension to XQuery 1.0) which is only available from 11.2.0.3 and onwards.
    On previous versions, you can use updateXML() function :
    SQL> SELECT updateXML(
      2           msg_cntnt_xml
      3         , '/Message/msgHdr/Source/Format/text()'
      4         , 'abc'
      5         ) xmlmct
      6  FROM (SELECT xmltype('<Message>
      7     <msgHdr>
      8        <Source>
      9           <Format>CTS</Format>
    10        </Source>
    11     </msgHdr>
    12  </Message>') msg_cntnt_xml
    13         FROM DUAL)
    14  ;
    XMLMCT
    <Message><msgHdr><Source><Format>abc</Format></Source></msgHdr></Message>

  • Using XQuery and XPath in Java

    Hi,
    I want to execute my XQuery Expression using Java. Jdk6.0 currently have the API for evaluating XPath Expressions. How do I do for the execution of my XQuery. If Jdk6.0 not having the support for XQuery what other things do I do for that. Give me some information regarding my problem.
    Thanks.
    Phani

    You can use Saxon to execute XQuery expressions.

  • XQuery syntax to evaluate math formula

    I want to evaluate a math formula inside of a function, so I can't use dynamic SQL.
    I found that the query on an XML-variable with a literal works well.
     DECLARE @sParsedFormula varchar(200);
     DECLARE @xFormula xml;
     SET @xFormula = '';
     SET @sParsedFormula = '1+2';
     SELECT @xFormula.query('3+3') , @xFormula.query('sql:variable("@sParsedFormula")')
    Output (1st value is correctly evaluated, 2nd not):
    "6", "1+2"
    I can't directly pass @sParsedFormula to the query otherwise I get "The argument 1 of the XML data type method "query" must be a string literal".
    What is the correct XQuery-syntax to evaluate the SQL:variable?
    Tx,
    Patrick

    You are obviously on the wrong track when you ask for the impossible.
    You can use sql:variable in XQuery to provide a value. You cannot provide an
    expression.
    If you want to pursue the set-up, your function will have to parse the expression and evalaute it. You can do this is in T-SQL, but it is not the best language for string parsing. Count on wast^H^H^H^Hspending quite a few hours on the development.
    If you do it in C#, undoubtedly it will be easier, and I would expect that you can find classes that performs the parsing and evaluation. This can reduce your development costs considerably.
    Of the languages I have worked with, there is one where the evaluting the expressions are dirt simple: Perl. Here you can just say
      $value = eval($expr)
    But running Perl code from SQL Server? Nah.
    If you want to do this in T-SQL only, it will have to be dynamic SQL. To avoid the cursor you can do somthing like:
       SELECT @sql =
         (SELECT 'SELECT ' + ltrim(str(id)) + ', ' + expr + ';' + char(13) + char(10)
          FROM   #temp
          FOR XML PATH(''), TYPE).value('.', 'nvarchar(MAX)')
      PRINT @sql
      INSERT #newtemp(id, value)
         EXEC (@sql)
      UPDATE #temp
      SET    value = n.value
      FROM   #temp t
      JOIN   #newtemp n ON t.id = n.id
    So, yes, XML had a place in your solution. But where you were looking.
    But note that with this solution, you will lose it all if one expression does not parse.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • XQuery is causing lots of disk writing

    Hi,
    In our system, we found that XQuery is causing lots of disk writing. I guess it is due to cache.
    In dbxml document, it says:
    All Berkeley DB XML applications are capable of writing temporary files to disk. This happens when the disk cache fills up and so BDB XML is forced to write overflow pages. For the most part, these temporary files can be safely ignored.
    I don't understand what it says above.
    My question is: Why Xquery operations will cause lots of disk write? (No other proocesses are writing bdb. )
    Thanks.
    -Yuan

    Hi Yuan,
    DB XML uses temporary Berkeley DB databases for a number of things during query evaluation, including re-sorting index entries and storing the parsed documents from a WholedocContainer format container. Berkeley DB will write this information out to disk if the cache becomes full. I would suggest that the behaviour you're seeing indicates that you need to allocate more cache for DB XML to work with.
    John

  • XQuery Performance in BerkeleyDB

    We are migrating from IPedo to Berkeley DB.
    IPedo did not support multiple indices in their Xqueries, so we had to
    concatenate some fields in to one field and index that field, the
    Xqueries were really fast.
    Unfortunately the same XQuery does not perform well in BerkeleyDB.
    This is how we create the index for this filed (ContentKey) in
    BerkeleyDB
    addIndex '' 'ContentKey' edge-element-equality-string
    and this is how I query using Java API.
    queryContext.setEvaluationType(XmlQueryContext.Eager);
    queryContext.setVariableValue("ContentKey", new XmlValue(
    "a0a0188000001115348efcc00000003XXXXXXXXXXXXXYYYYYYYYYYYYYY"));
    // Declare the query string
    String myQuery = "collection('db/title')/Record[ContentKey=
    $ContentKey]";
    // Prepare (compile) the query
    XmlQueryExpression xmlQueryExpression =
    dbManager.prepare(myQuery,queryContext);
    1. What is wrong with the index or the way I am using the Java API ?
    Changing the evaluation type to Lazy did not help at all.
    2. The Query performs OK in dbxml.
    3. Are there any other commercial/open source tools to evaluate the
    performance of a Xquery in BerkeleyDB? Stylus Studio does not support
    BDB - 2.3.10 yet.
    Any help would be appreciated.
    Thanks,
    Suresh

    Hi John:
    Thanks for your mail.
    I did declare variable as xs:string external, it did not work. I heard from other engineers in the group that since 2.3.8, “external” variables in BerkeleyDB stopped working. We are using 2.3.10.
    I also noticed that the query plan when we using external variables is not valid XML (<GlobalVar name="var external="true">). I hope this is just a toString() issue and nothing major.
    I have attached the query plans; I do not see anything different between the two. I would really appreciate your help on this.
    Thanks,
    Suresh
    Here are the query plans:
    Query that executes in 2 ms (which has the hard coded value):
    Query:
    String myQuery = "declare namespace tf = \"http://aplaud.com/ns/0.1/tts/format\";" +
    "count (collection('db/title')/Record[ContentKey=\"a0a0188000001115348efcc00000003http://daxweb.org/ns/1.0/taxonomy/Product Type/Gift Receipt\"]/tf:TitleDocument/tf:Title/Content/Detail/GiftInfo/Gift)";
    Query Plan:
    <XQuery>
    <Function name="{http://www.w3.org/2005/xpath-functions}:count">
    <DocumentOrder>
    <DbXmlNav>
    <LookupIndex container="db/title">
    <ValueQP index="edge-element-equality-string" operation="eq" parent="Record" child="ContentKey" value="a0a0188000001115348efcc00000003http://daxweb.org/ns/1.0/taxonomy/Product Type/Gift Receipt"/>
    </LookupIndex>
    <Join type="parent-of-child" return="argument">
    <DbXmlNav>
    <QueryPlanFunction result="collection" container="db/title">
    <OQPlan>V(edge-element-equality-string,Record.ContentKey,=,'a0a0188000001115348efcc00000003http://daxweb.org/ns/1.0/taxonomy/Product Type/Gift Receipt')</OQPlan>
    </QueryPlanFunction>
    <DbXmlStep axis="child" name="Record" nodeType="element"/>
    </DbXmlNav>
    </Join>
    <DbXmlStep axis="child" prefix="tf" uri="http://aplaud.com/ns/0.1/tts/format" name="TitleDocument" nodeType="element"/>
    <DbXmlStep axis="child" prefix="tf" uri="http://aplaud.com/ns/0.1/tts/format" name="Title" nodeType="element"/>
    <DbXmlStep axis="child" name="Content" nodeType="element"/>
    <DbXmlStep axis="child" name="Detail" nodeType="element"/>
    <DbXmlStep axis="child" name="GiftInfo" nodeType="element"/>
    <DbXmlStep axis="child" name="Gift" nodeType="element"/>
    </DbXmlNav>
    </DocumentOrder>
    </Function>
    </XQuery>
    Query that executes takes 4 seconds (which has the declared var as xs:string external):
    Query:
    String myQuery = "declare namespace tf = \"http://aplaud.com/ns/0.1/tts/format\"; declare variable $var as xs:string external;" + "count (collection('db/title')/Record[ContentKey=$var]/tf:TitleDocument/tf:Title/Content/Detail/GiftInfo/Gift)";
    Query Plan:
    <XQuery>
    <GlobalVar name="var external="true">
    <SequenceType occurrence="exactly_one" testType="atomic-type" type="http://www.w3.org/2001/XMLSchema:string"/>
    </GlobalVar>
    <Function name="{http://www.w3.org/2005/xpath-functions}:count">
    <DocumentOrder>
    <DbXmlNav>
    <LookupIndex container="db/title">
    <ValueQP index="edge-element-equality-string" operation="eq" parent="Record" child="ContentKey">
    <Variable name="var"/>
    </ValueQP>
    </LookupIndex>
    <Join type="parent-of-child" return="argument">
    <DbXmlNav>
    <QueryPlanFunction result="collection" container="db/title">
    <OQPlan>P(edge-element-equality-string,prefix,Record.ContentKey)</OQPlan>
    </QueryPlanFunction>
    <DbXmlStep axis="child" name="Record" nodeType="element"/>
    </DbXmlNav>
    </Join>
    <DbXmlStep axis="child" prefix="tf" uri="http://aplaud.com/ns/0.1/tts/format" name="TitleDocument" nodeType="element"/>
    <DbXmlStep axis="child" prefix="tf" uri="http://aplaud.com/ns/0.1/tts/format" name="Title" nodeType="element"/>
    <DbXmlStep axis="child" name="Content" nodeType="element"/>
    <DbXmlStep axis="child" name="Detail" nodeType="element"/>
    <DbXmlStep axis="child" name="GiftInfo" nodeType="element"/>
    <DbXmlStep axis="child" name="Gift" nodeType="element"/>
    </DbXmlNav>
    </DocumentOrder>
    </Function>
    </XQuery>

  • XQuery Performance in BerkeleyDB More options

    We are migrating from IPedo to Berkeley DB.
    IPedo did not support multiple indices in their Xqueries, so we had to
    concatenate some fields in to one field and index that field, the
    Xqueries were really fast.
    Unfortunately the same XQuery does not perform well in BerkeleyDB.
    This is how we create the index for this filed (ContentKey) in
    BerkeleyDB
    addIndex '' 'ContentKey' edge-element-equality-string
    and this is how I query using Java API.
    queryContext.setEvaluationType(XmlQueryContext.Eager);
    queryContext.setVariableValue("ContentKey", new XmlValue(
    "a0a0188000001115348efcc00000003XXXXXXXXXXXXXYYYYYYYYYYYYYY"));
    // Declare the query string
    String myQuery = "collection('db/title')/Record[ContentKey=
    $ContentKey]";
    // Prepare (compile) the query
    XmlQueryExpression xmlQueryExpression =
    dbManager.prepare(myQuery,queryContext);
    1. What is wrong with the index or the way I am using the Java API ?
    Changing the evaluation type to Lazy did not help at all.
    2. The Query performs OK in dbxml.
    3. Are there any other commercial/open source tools to evaluate the
    performance of a Xquery in BerkeleyDB? Stylus Studio does not support
    BDB - 2.3.10 yet.
    Any help would be appreciated.
    Thanks,
    Suresh

    Hi,
    I'm sorry, you're in the wrong forum. Please post to the Berkeley DB XML forum:
    Berkeley DB XML
    Thanks,
    Mark

  • Automated Testcase for XQuery

    Hi,
    I am using Oracle JDeveloper 11g Release 1.
    Can you please tell me how to write automated test cases for XQuery.
    I found one tutorial on net (http://oracamp.com/automatic-xquery-unit-tests-osb-projects-0), tried executing the same steps as mentioned with the same examples.
    But getting exceptions while trying to do so.
    I am not sure whether it is a problem with jar or something else.
    Please let me know how to proceed further.
    I am getting the following exception -
    oracle.xquery.XQException: XPTY0004: It is a type error if, during the static analysis phase, an expression is found to have a static type that is not appropriate for the context in which the expression occurs, or during the dynamic evaluation phase, the dynamic type of a value does not match a required type as specified by the matching rules in 2.5.4 SequenceType Matching.
    Detail: Encounter a type error during the static type checking phase
    oracle.xquery.exec.StaticTypingVisitor.raiseStaticTypeError(StaticTypingVisitor.java:1888)
    oracle.xquery.exec.StaticTypingVisitor.handleError(StaticTypingVisitor.java:1903)
    oracle.xquery.exec.StaticTypingVisitor.handleError(StaticTypingVisitor.java:1897)
    oracle.xquery.exec.StaticTypingVisitor.normalizeParameter(StaticTypingVisitor.java:348)
    oracle.xquery.exec.StaticTypingVisitor.visitFunctionDefn(StaticTypingVisitor.java:2615)
    oracle.xquery.func.FunctionDefn.staticTypeChecking(FunctionDefn.java:154)
    oracle.xquery.exec.QueryState.staticTypingFnDecls(QueryState.java:1022)
    oracle.xquery.PreparedXQuery.staticTyping(PreparedXQuery.java:511)
    oracle.xquery.PreparedXQuery.prepare(PreparedXQuery.java:434)
    oracle.xquery.PreparedXQuery.executeQuery(PreparedXQuery.java:544)
    oracle.xquery.PreparedXQuery.executeQuery(PreparedXQuery.java:562)
    unittest.XQUnit.runQuery(XQUnit.java:123)
    unittest.XQUnit.testXQuery(XQUnit.java:83)
    unittest.AchternaamTest.testTransformation1(AchternaamTest.java:11)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    java.lang.reflect.Method.invoke(Method.java:597)
    junit.framework.TestCase.runTest(TestCase.java:168)
    junit.framework.TestCase.runBare(TestCase.java:134)
    junit.framework.TestResult$1.protect(TestResult.java:110)
    junit.framework.TestResult.runProtected(TestResult.java:128)
    junit.framework.TestResult.run(TestResult.java:113)
    junit.framework.TestCase.run(TestCase.java:124)
    junit.framework.TestSuite.runTest(TestSuite.java:243)
    junit.framework.TestSuite.run(TestSuite.java:238)
    Thanks,
    Deepthi

    Hello,
    I am still looking into this, but upon closer examination here is the situation, basically as reported.
    The test calls set_thread_count which sizes the memory. In __env_attach(), (dbenv->thr_max is used to size the region. So you are correct, the higher the value used in set_thread_count, the larger the size of the region will be. Eventually that memory will be depleted, and __env_alloc_size() returns ENOMEM, after multiple calls to system(db_stat). __env_alloc_free() is not called. This is the part I am still investigating.
    The test uses system to fork a separate processes for db_stat and the failing stack is:
    lt-db_stat: assert failure: ../dist/../env/env_failchk.c/426: "ret == 0"
    lt-db_stat: __os_stack+0x2b
    lt-db_stat: __os_abort+0x1d
    lt-db_stat: __db_assert+0x47
    lt-db_stat: __env_set_state+0x53c
    lt-db_stat: __env_attach_regions+0x38b
    lt-db_stat: __env_open+0x154
    lt-db_stat: __env_open_pp+0x334
    lt-db_stat: lt-db_stat
    So db_stat is opening an environment, attaching to its region, and then __env_set_state() calls __env_alloc(). It is __env_alloc() which fails with ENOMEM after some point when there is no more space to be allocated from the shared region. And I'm still looking into that space would be returned to the shared region.
    Thanks,
    Sandra

  • OSB & xquery: when use text() or data(...)

    Hi all,
    I'm a beginner on xquery and I'm wondering when use text() or data(...).
    For example I've this simple xml document:
    <book>
    <author>A</author>
    <year>2010</year>
    <price currency="CHF" >100.123</price>
    </book>
    for retrieving attribute value I have to use data(/book/price/@currency)
    but for for retrieving tag value I've two possibilities:/book/price/text() or data(/book/price)
    Are those two expressions the same ? Or ones is evaluated faster than the others ?

    Text() - always returns the String.
    data() - accepts a sequence of items and returns their typed values (return type is xs:anyAtomicType). Calling this function is often unnecessary because the typed value of a node is extracted automatically (in a process known as atomization) for many XQueryXPath 2.0 expressions, including comparisons, arithmetic operations and function calls. The most common use case for the fn:data function is in XQuery element constructors.
    Regards,
    Anuj

  • Function "xmlnamespaces" gives PL/SQL: ORA-19102: XQuery string literal....

    Below is my script that you can run successfully, and i have version Oracle 11g.
    Script has Xml namespace as constant at the moment there:
       xmlnamespaces(default 'http://elion.ee/webservices/Sales/Dynamics')I want to have a variable there instead, like this:
       xmlnamespaces(default    l_sSOAP_Namespace )But if i add such variable there i get such error:
    PL/SQL: ORA-19102: XQuery string literal expectedCan i avoid such error somehow and use still the namespace as variable somehow, not the constant?
    My script:
    declare
       l_resp varchar2(4000);
       l_sSOAP_Namespace varchar2(4000) := 'http://elion.ee/webservices/Sales/Dynamics';
    begin
      l_resp :=
      '<ns0:FindItemMetaDataResponse xmlns:ns0="http://elion.ee/webservices/Sales/Dynamics">
            <ns0:ItemMetaData>
              <ns0:ItemMetaData>
                <ns0:ItemGroupId>IT.LS.VS.DSL</ns0:ItemGroupId>
                <ns0:ItemGroupName>IT lisad võrguseadmed DSL</ns0:ItemGroupName>
                <ns0:ItemId>DSLGP603</ns0:ItemId>
                <ns0:ItemName>ADSL SIP ST546</ns0:ItemName>
               <ns0:ItemType>Item</ns0:ItemType>
               <ns0:MacAddressMandatory>No</ns0:MacAddressMandatory>
               <ns0:SalesUnit>tk</ns0:SalesUnit>
               <ns0:SerialNumMandatory>No</ns0:SerialNumMandatory>
               <ns0:TaxValue>20.00</ns0:TaxValue>
             </ns0:ItemMetaData>
             <ns0:ItemMetaData>
               <ns0:CurrencyCode>EUR</ns0:CurrencyCode>
               <ns0:ItemGroupId>KL.PS.HGW</ns0:ItemGroupId>
               <ns0:ItemGroupName>Ruuterid</ns0:ItemGroupName>
               <ns0:ItemId>DSLGP603NY</ns0:ItemId>
               <ns0:ItemName>ADSL stardikomplekt Thomson ST546 stardi</ns0:ItemName>
               <ns0:ItemType>Item</ns0:ItemType>
               <ns0:MacAddressMandatory>No</ns0:MacAddressMandatory>
               <ns0:PriceWithoutVAT>12.78</ns0:PriceWithoutVAT>
               <ns0:PriceWithVAT>15.34</ns0:PriceWithVAT>
               <ns0:SalesUnit>tk</ns0:SalesUnit>
               <ns0:SerialNumMandatory>Yes</ns0:SerialNumMandatory>
               <ns0:TaxValue>20.00</ns0:TaxValue>
             </ns0:ItemMetaData>
           </ns0:ItemMetaData>
         </ns0:FindItemMetaDataResponse>';
      for rec in
         with xml_doc (doc) as (
            select xmlparse(document
            l_resp)
           from dual
         select x.*
         from xml_doc t
            , xmltable (
                xmlnamespaces(default 'http://elion.ee/webservices/Sales/Dynamics')
              , '/FindItemMetaDataResponse/ItemMetaData/ItemMetaData'
                passing t.doc
                columns
                CurrencyCode varchar2(4000) path 'CurrencyCode',
                ItemGroupId varchar2(4000) path 'ItemGroupId',
                ItemGroupName varchar2(4000) path 'ItemGroupName',
                ItemId varchar2(4000) path 'ItemId',
                ItemName varchar2(4000) path 'ItemName',
                ItemType varchar2(4000) path 'ItemType',
                MacAddressMandatory varchar2(4000) path 'MacAddressMandatory',
                PriceWithoutVAT varchar2(4000) path 'PriceWithoutVAT',
                PriceWithVAT varchar2(4000) path 'PriceWithVAT',
                SalesUnit varchar2(4000) path 'SalesUnit',
                SerialNumMandatory varchar2(4000) path 'SerialNumMandatory',
                TaxValue varchar2(4000) path 'TaxValue'         
              ) x
      ) loop
        dbms_output.put_line('ItemId=' || rec.ItemId);
      end loop;
    end;
    /* Output:
    ItemId=DSLGP603
    ItemId=DSLGP603NY
    */Edited by: CharlesRoos on 11.04.2013 14:46

    How badly do you need the namespace to be dynamic ?
    Is it likely to change that frequently?
    The reason for having to hardcode namespace declarations and XQuery string in general is optimization.
    By doing so, the CBO is able to analyze the whole expression and apply optimization techniques such as XQuery rewrite.
    As said, use dynamic SQL if you really have no way around this requirement.
    The other solution I'm reluctent to expose here is to make the whole thing namespace-free by using construct such as "*:element-name" or "*[local-name()="element-name"]".
    Both will use XQ functional evaluation and perform worse.

Maybe you are looking for

  • Incorrect Open_Amount for credit items in process receivable screen

    In Collections Management (UDM_SUPERVISOR, UDM_SPECIALIST) EP4, in the process receivables screen, there are credit items which show open amount  (OPEN_AMOUNT field) as '0' even when there is an actual non zero open credit amount for that credit item

  • Amended Columns in IR not showing in Edit Form

    Hi, I Created a IR report using A form on a report wizard. I have now changed the underlying query in the IR and it is showing correct. When I click on Edit, the records are not forwarded to the form. Even the new fields in the IR are not reflected i

  • Cover flow is completely bugged out and won't display correctly

    Awhile back, one of my displays which held a maximized iTunes window was accidentally unplugged, which somehow caused the iTunes window to shrink beyond its allowed limits. Ever since, I've had this problem when I try to use cover flow on the Music o

  • How do I delete a network and start over with no wired computers??

    I've been trying forever to delete my parents network...it has a WEP I can't remember, and I just want to start from scratch.  I've tried reseting the router...I've even called a Linksys tech, and even she was baffled.  I have no wired computers...Ca

  • Parallel Currency Urgent simple question

    How can I figure out if my client is using Parallel Currency Valuation. Please let me know. I have used  T.code OB22 however I dont see our company code in the overview screen.