[Zope] ZSQL testing for empty return from select
David Salgado
David@connmed.co.uk
Wed, 2 Feb 2000 16:57:08 -0000
Hi all
I've got a problem with a ZSQL method which looks like;
select max(<dtml-var key_field>) as keyval from <dtml-var table_name>
This works perfectly as long as there is at least one record in the table,
but seems to just hang if the table is empty.
I'm trying to use this method from an external method as follows;
res = self.qryMaxKey(table_name='events', key_field='eventid')
# Test for empty return here
return res[0][0]
so I've tried tests like;
if not res: return 0
if res == []: return 0
if res == None: return 0
but none of these seem to work.
All ideas gratefully receved!
TIA
David