dynamic queries
Hi,
I'm having problems with dynamic queries I create on the fly in oml.
I really would be gratefull for any help.
In my application I allow user to define the logical structure of database . All that information (entities/attributes definitions, inluding my own types: locations, styles, colors, symbols) are stored in meta-data part of my database.
Data iself are stored in such a way that there is one table which stores ids of all entitites (and of course type of entity), but all attributes of entities are stored in seperate tables for each specific type (there is seperate table to store all 'int' attributes, seperate to store 'locations' attribute, seperate to store 'strings'...).
Then based on that metadata I build queries to retrieve entity data
1. based on entity definition I construct single query which is supposed to retrieve entity data
Simple example of Person entity:
SELECT entity.id,
firstname.value AS firstname,
lastname.value AS lastname,
birthyear.value AS birthyear
FROM data_entity as entity
LEFT JOIN data_attr_string as firstname
ON firstname.data_id = entity.id AND firstname.attr_id = 'firstname'
LEFT JOIN data_attr_string as lastname
ON lastname.data_id = entity.id AND lastname.attr_id = 'lastname'
LEFT JOIN data_attr_int as birthyear
ON birthyear.data_id = entity.id AND birthyear.attr_id = 'birthyear'
WHERE entity.entity_id = 'Person'
Notice that firstname,lastname,birthyear are attributes defined by user and are stored in meta-data.
3. Now having above query and entity definition I would like to retrieve data but I'm not able to do this
<db:execute connection="wisdom" sql="{$viewQuery}">
<data>
HOW TO ACCESS 'firstname' ,'lastname' attributes here since these name are stored in some variables and are not know at OML compilation time?
</data>
</db:execute>
'firstname' name is know in runtime not in compilation time, so I can't use {$firstname} statement.
I need to use something like {$<o:eval select="attributeName"/>} which of course doesn't work.
Thanks for any hints !
Tomasz Rakowski
PS.
I thought about generating and compiling oml on fly but above aproach seems to me be little more simple (of course if it would be feasible).
I could also retrieve entity data using several seperate queries (for each seperate attribute) but it would be much
slower (specially in case of entity lists...)
Cheap Talk? Check out Yahoo! Messenger's low PC-to-Phone call rates.
_______________________________________________ o-xml mailing list o-xml@... http://lists.pingdynasty.com/mailman/listinfo/o-xml
RSS Feed