Re: dynamic queries
[email protected] Tue, 14 Nov 2006 11:18:23 +0000 (GMT)
| Newsgroups | gmane.text.xml.o-xml |
|---|---|
| Message-ID | <[email protected]> |
Hi Tomasz,
I think this was maybe answered in response to your other mail, let me know if you still have problems with this.
Another approach might be to treat the problem as two sets of data; one being the database result, the other the dynamic information necessary to execute the query. You can then merge the two into whatever form you require.
You could also use o:XML types to represent the datastructures, then set the dynamic values programmatically.
For example, if you define a type DataEntity with a suitable constructor and setter functions, then:
<o:variable name="entities">
<db:execute sql="...">
<o:eval select="DataEntity($firstname, $lastname, $birthyear)"/>
<!-- creates one DataEntity for each row in result set -->
</db:execute>
</o:variable>
<o:do select="$entities.SetSomeAttribute('firstname')"/>
<!-- sets some attribute on _all_ DataEntity objects in $entities -->
Now if you want to produce an XML result set from the DataEntity object, you can overload the nodes() function to do so. Eg
<o:type name="DataEntity">
...
<o:function name="nodes">
<o:do>
<entity><o:eval select="$SomeAttribute"/></entity>
</o:do>
</o:function>
</o:type>
hope this makes sense -
there's lots more you could do with o:XML types, let me know if you want any more specific info!
/m
On 12 Nov 2006, at 17:50, Tomasz Rakowski wrote:
Hi,
I'm having problems with dynamic queries I create on the fly in oml.
I really would be gratefull for any help.