Forum Stats

  • 3,827,928 Users
  • 2,260,839 Discussions
  • 7,897,408 Comments

Discussions

Xquery External Variable Binding

656631
656631 Member Posts: 18
edited Oct 25, 2008 7:06AM in XML DB
Hi everyone...

Can anyone throw some light on external variable binding in xquery with Oracle 11G XMLDB?

declare $foo as xs:string external;

Thanks in advance,

Regards,
Kaja
Tagged:

Best Answer

  • Ants Hindpere
    Ants Hindpere Member Posts: 325 Bronze Badge
    you can use passing clause like in xmltable for example
    SQL> with t as (select xmltype('<a><b>1</b><b>2</b></a>') xcol from dual)
      2  select x.*
      3  from t
      4      ,xmltable('for $i in $AA/a/b where $i=$bind_val return $i'
      5        passing t.xcol as "AA"
      6                ,2 as "bind_val"
      7        columns val number path '.') x;
    
           VAL                                                                      
    ----------                                                                      
             2                                                                      

Answers

  • Ants Hindpere
    Ants Hindpere Member Posts: 325 Bronze Badge
    you can use passing clause like in xmltable for example
    SQL> with t as (select xmltype('<a><b>1</b><b>2</b></a>') xcol from dual)
      2  select x.*
      3  from t
      4      ,xmltable('for $i in $AA/a/b where $i=$bind_val return $i'
      5        passing t.xcol as "AA"
      6                ,2 as "bind_val"
      7        columns val number path '.') x;
    
           VAL                                                                      
    ----------                                                                      
             2                                                                      
  • Marco Gralike
    Marco Gralike Member Posts: 4,491 Silver Trophy
    edited Oct 24, 2008 3:31PM
    Hi Ants.

    Is there an alternative for ora:view while using an xmltype table for source...(see: 721761

    Sorry for the interruption ;-)

    Edited by: Marco Gralike on Oct 24, 2008 9:31 PM
  • Ants Hindpere
    Ants Hindpere Member Posts: 325 Bronze Badge
    Hi Marco,

    besides those possibilities in here 721761

    it's also possible to use doc(:uriType)

    btw, there's a shorter version of ora:view() ;)
    SQL> select * from
      2  xmltable('ora:view("XTAB")/site/people/person[@id="person0"]/name/text()');
    
    COLUMN_VALUE                                                                    
    --------------------------------------------------------------------------------
    Jaak Tempesti                                                                   
    
    SQL> spool off;
    Ants
  • Marco Gralike
    Marco Gralike Member Posts: 4,491 Silver Trophy
    Thanks Ants
    good suggestion

    I though that doc(:uriType) could't be used for tables (I will check it) ?
  • Ants Hindpere
    Ants Hindpere Member Posts: 325 Bronze Badge
    I though that doc(:uriType) could't be used for tables (I will check it) ?
    my bad, I forgot that your data is in a table.
    You can use doc() only if it's created with dbms_xdb.createresource
This discussion has been closed.