[xquery-talk] SQL to XML with XQuery?

Ihe Onwuka ihe.onwuka at gmail.com
Wed Aug 9 23:13:42 PDT 2017


DB2 version 10 onwards lets you mix SQL and XQuery commands in one query.

On Thu, Aug 10, 2017 at 2:07 AM, <xquery at docbook-autor.de> wrote:

>
>  Hi,
>
> I know that XQuery is typically used for transforming XML into other
> text file formats.
>
> But is it possible to use XQuery for the other way round?
>
> I want to transform a very simple SQL Create Table statement into XML.
>
>
> SQL
> ===
>
> CREATE TABLE mytable1
>
> (
>   FIELD1        xxx;
>   FIELD2        xxx;
>   FIELD3        xxx;
> );
>
> COMMENT ON COLUMN mytable1.FIELD1 'Description1';
> COMMENT ON COLUMN mytable1.FIELD2 'Description2';
>
> CREATE TABLE mytable2
>
> (
>   FIELD1        xxx;
>   FIELD2        xxx;
>   FIELD3        xxx;
> );
>
> COMMENT ON COLUMN mytable2.FIELD1 'Description1';
> COMMENT ON COLUMN mytable2.FIELD3 'Description3';
>
>
> XML
> ===
>
> <table>
>   <title>mytable1</title>
>   <column>
>     <name>FIELD1</name>
>     <comment>Description1</comment>
>   </column>
>   <column>
>     <name>FIELD2</name>
>     <comment>Description2</comment>
>   </column>
>   <column>
>     <name>FIELD1</name>
>     <comment></comment>
>   </column>
> </table>
>
> <table>
>   <title>mytable2</title>
>   <column>
>     <name>FIELD1</name>
>     <comment>Description1</comment>
>   </column>
>   <column>
>     <name>FIELD2</name>
>     <comment></comment>
>   </column>
>   <column>
>     <name>FIELD1</name>
>     <comment>Description3</comment>
>   </column>
> </table>
>
> Can this be done via XQuery? If not which tool could possibly fit my needs?
>
> Best regards
> Michael
> _______________________________________________
> talk at x-query.com
> http://x-query.com/mailman/listinfo/talk
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://x-query.com/pipermail/talk/attachments/20170810/36624e38/attachment.html>


More information about the talk mailing list