Subject Re: [firebird-support] Re: Firebird SQL extract to XML: Possible?
Author Michael Ludwig
karolbieniaszewski schrieb am 22.03.2011 um 06:59 (-0000):

> XML is text based then write text concatenation
>
> SELECT
> '<element>' ||
> '<bar> || f.foo || '</bar>' ||
> '</element>'
> FROM DBTable f
> WHERE f.ID="fooid"

This approach will fall flat on its face at the first occurrence of a
reserved character.

> of course simplest is write stored proc for this with combination of
> execute statement

This won't solve the fundamental problem of producing proper XML.

Don't reinvent the wheel. You have database drivers that are good at
fetching data from the database, and you have XML producing libraries
that will produce the XML for you. All you have to do is to wire them
up and you're done.

Example for Perl:

* DBD::InterBase
* XML::LibXML

If you've got reasonable column names throughout (legal XML names), you
just reuse them as element names. Else give your elements boring names
such as <col name="my stupid column name with whitespace">.

Probably about 20 lines of code to write.
--
Michael Ludwig