[Zope-DB] zsql method w/ more than one field failing?

Charlie Clark charlie@begeistert.org
Wed, 28 May 2003 00:22:45 +0200


On 2003-05-28 at 00:08:54 [+0200], Christopher Heschong wrote:
> OK, I have a very simple sql method.  It has 2 arguments (inet, 
> client_hostname).  Here's the text of the method:
> 
> select * from lease
>   <dtml-sqlgroup where>
>     <dtml-sqltest inet type=nb op=eq optional>
>   <dtml-and>
>     <dtml-sqltest client_hostname type=nb op=eq optional>
>   </dtml-sqlgroup>
> 
> When I click on "test" and put in the value 'a' for inet and the value 
> 'b' for client_hostname, it returns this sql query:
> 
> select * from lease
>   where
> client_hostname = 'b'

Hi Chris,

I'm not a fan of <dtml-sql> at all. I find it very hard to read and 
personally prefer to use straight SQL with DTML-ifs at the most.

Why not simply try
SELECT * FROM lease
WHERE
inet = <dtml-sqlvar a type="nb" optional>
AND
client_hostname = <dtml-sql var b type="nb" optional>

I find it much easier to match the rendered SQL with what I want.

Charlie