[Zope-DB] Form evaluation in ZSQL-Method
Jim Abramson
jabramson at wgen.net
Thu Sep 18 10:42:00 EDT 2003
> The Z SQL method looks like
>
> <params>iditem</params>
> SELECT item FROM itmes
> <dtml-sqlgroup where>
> <dtml-sqltest iditem column=iditem op=eq type=eq optional>
> </dtml-sqlgroup>
>
> This perfectly selects the items if I select one of them but if I want to
> get all items nothing will be found.
I admit i haven't tried it...but have you tried wrapping that clause in a dtml-if?
SELECT item FROM itmes
<dtml-sqlgroup where>
<dtml-if "iditem>0">
<dtml-sqltest iditem column=iditem op=eq type=int>
</dtml-if>
</dtml-sqlgroup>
-----Original Message-----
From: Andreas Tille [mailto:tillea at rki.de]
Sent: Thursday, September 18, 2003 7:54 AM
To: Zope-DB at zope.org
Subject: [Zope-DB] Form evaluation in ZSQL-Method
Hi,
I want to implement the folowing logic:
If no item form a selection List is selected, I want to get all items from
the database as return. In a selection list I defined
<option value="0">All items</option>
<option value="1">Item 1</option>
<option value="2">Item 2</option>
<option value="3">Item 3</option>
The Z SQL method looks like
<params>iditem</params>
SELECT item FROM itmes
<dtml-sqlgroup where>
<dtml-sqltest iditem column=iditem op=eq type=eq optional>
</dtml-sqlgroup>
This perfectly selects the items if I select one of them but if I want to
get all items nothing will be found. I wanted to do the following
trick now:
I defined in PostgreSQL
CREATE FUNCTION test_item (integer, integer) RETURNS boolean AS '
BEGIN
IF $1 = 0 OR $2 = 0 OR $1 = $2 THEN
RETURN ''t'' ;
END IF;
RETURN ''f'' ;
END; ' LANGUAGE 'plpgsql';
which returns true in the case that one integer is zero or if both are
equal. To use this I tried the following ZSQL variation:
<params>iditem</params>
SELECT item FROM itmes
<dtml-sqlgroup where>
test_land(<dtml-sqlvar iditem type="nb">, iditem)
</dtml-sqlgroup>
This works for the first 20 results of the result set but if I want to
follow the link "Next 20 results" I get the answer
Missing input variable, iditem
Any hint what's wrong here or rather, how to do this right?
Kind regards
Andreas.
_______________________________________________
Zope-DB mailing list
Zope-DB at zope.org
http://mail.zope.org/mailman/listinfo/zope-db
More information about the Zope-DB
mailing list