[Zope] zsql-Methods: how to make a dynamic where-clause?
Satheesh Babu
vattekkat.babu at verizon.net
Fri Aug 8 12:09:33 EDT 2003
Elena,
you could pass a parameter like params={'col1':'val1', 'col2':'val2'}
and write you SQL method like:
select * from table <dtml-sqlgroup where>
<dtml-in "params.keys()">
<dtml-var sequence-item> = '<dtml-var "params[_['sequence-value']]">'
<dtml-unless sequence-end> and </dtml-unless>
</dtml-in>
</dtml-sqlgroup>
you can extend this to check for types, different condition joiners etc.
Babu
--
http://vsbabu.org/
Elena Schulz wrote:
> Hi,
>
> is there any convenient way, to have a dynamic where-clause in zsql-Methods?
> All my effords had severe limitation up to now:
> 1. <dtml-sqltest .. needs a fixed column=.... expression
> 2. WHERE <dtml-var ...> with the whole clause in the var doesn't work
> because of quoting problems.
> ...
> So it seems that there is only very limited scope with <sql-group and
> explicit column=myExplicitColumnName constructs or am I missing
> something? A completely dynamic query with python script would be also a
> good alternative but how to do that?
>
> -- thanks for any input, Elena
>
>
> _______________________________________________
> Zope maillist - Zope at zope.org
> http://mail.zope.org/mailman/listinfo/zope
> ** No cross posts or HTML encoding! **
> (Related lists -
> http://mail.zope.org/mailman/listinfo/zope-announce
> http://mail.zope.org/mailman/listinfo/zope-dev )
>
More information about the Zope
mailing list