Example 5  Example 7

Chapter 2: XML Services

Example 6

You apply a relative function call as a step in a path. Evaluating that path produces a sequence of XML nodes, and performs a relative function call for each node.The result is a sequence of the function call results. For example, this query produces a sequence of first_name nodes:

select xmlextract( '/bookstore/book/author/first-name', text_doc)
from sample_docs where name_doc='bookstore'
---------------------------------
<first-name>Joe</first-name><first-name>Mary</first-name>
<first-name>Toni</first-name> 

The query below replaces the last step of the previous query with a call to toupper, producing a sequence of the results of both function calls.

select xmlextract('/bookstore/book/author/toupper(first-name)', text_doc)
from sample_docs where name_doc='bookstore'
----------------------------------
JOEMARYTONI 

Now you can use concat to punctuate the sequence of the function results. See the example in “concat”.





Copyright © 2004. Sybase Inc. All rights reserved. Example 7

View this book as PDF