Home » SQL & PL/SQL » SQL & PL/SQL » XQuery Basic Help
icon8.gif  XQuery Basic Help [message #239811] Wed, 23 May 2007 06:23 Go to next message
mdoubledragon
Messages: 2
Registered: May 2007
Junior Member
Hi Guys!
I am loggin in to oracle with my username "sam" and I have a table "book" containing column of XMLType "bookInfo". It has the following entry:
<book>
<title>Hello World</title>
</book>

Please tell me the basic XQuery to return the title of this book.

I have previous experience using XQuery with DB2 but the passing bookInfo as "bookInfo" is of course not working with oracle.
I searched many tutorials but I get lost in ora:view or doc functions.

Thanks for your time.

[Updated on: Wed, 23 May 2007 09:54]

Report message to a moderator

Re: XQuery Basic Help - not urgent at all [message #239880 is a reply to message #239811] Wed, 23 May 2007 09:36 Go to previous messageGo to next message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
SQL> with xml_source as (select xmltype('<book><title>Hello World</title></book>' ) xml from dual)
2 select extractvalue(xml,'/book/title')
3 from xml_source;

EXTRACTVALUE(XML,'/BOOK/TITLE')
---------------------------------------------------------------------------------------------------
Hello World
Re: XQuery Basic Help - not urgent at all [message #239888 is a reply to message #239880] Wed, 23 May 2007 09:54 Go to previous message
mdoubledragon
Messages: 2
Registered: May 2007
Junior Member
Thanks but I am looking for the FLWOR type implementation.
It should be something like:

for $book in $books
let $title:=$book/title
return <title>{$title}</title>

Its just that I cant figure out how to pass my table "book" to $books variable in the query. Thats the thing I want help with.
Previous Topic: set off
Next Topic: Left join problem
Goto Forum:
  


Current Time: Sun Dec 11 02:39:30 CST 2016

Total time taken to generate the page: 0.07733 seconds