[xquery-talk] Extracting XML data from a Table in PosgreSQL

Peter pc.subscriptions at gmail.com
Thu Dec 27 13:33:39 PST 2007


> queries, but I don't know of one that does this - the DataDirect engine,
> which has this general architecture, will allow you to use XQuery
> against
> data stored in relational form, but not (as far as I am aware) against
> XML
> stored in a relational database as text.
Actually...it is possible using an extension function (ddtek:parse).

The doc has an example

create table xmltab (key int primary key, xmlval varchar(2000))
insert into xmltab values(1,'<a><b>1</b><b>11</b></a>')
insert into xmltab values(2,'<a><b>2</b><b>22</b></a>')

The following query returns the key value and b elements from
the xmlval column for every b element that contains a value
greater than 10:

for $x in collection('xmltab')/xmltab
let $y := ddtek:parse($x/xmlval)//b[xs:integer(.) > 10]
return (data($x/key),$y)

I am unfamiliar with the latest changes in terms of product architecture,
but with the last version I knew some of the internals, this approach would
only be practically feasible on 'smaller' XML fragments. 



More information about the talk mailing list