5. Example

ここでは, XPath処理関数を用いた例をいくつか挙げる.

-- convert XPath to SQL
select xpath2sql('/site/open_auctions/open_auction');

-- above query is equals to
select xpath2sql('/site/open_auctions/open_auction',0);

-- return SQL that extracts ordered flagment
select xpath2sql('/site/open_auctions/open_auction',3);

-- evaluation xpath
select * from xpath_eval('/site/open_auctions/open_auction');
select * from xpath_eval('/site/open_auctions/open_auction',3);

-- evaluation '/PLAY' and set selected node-content "hoge"
UPDATE
    xml_node
SET
    content = 'hoge'
FROM
    xpath_eval('/PLAY') as Q
WHERE
    xml_node.id = Q.id;