[Zope] Simple, I think!

Mark N. Gibson mark@kaivo.com
Wed, 25 Jul 2001 15:35:56 -0600 (MDT)


Generally speaking, when you do a query, you want the results of your query,
not just the number of records.  The original poster implies that this is
what (s)he's looking for.  It's inefficient to do two queries when one will 
suffice.

So when you do the following, you get the number of records, as well as
the result set that can be used in a dtml-in.

<dtml-let results="SQL_Select()">
 #Results returned = <dtml-var "_.len(results)">
 </dtml-let>

However, as somene has already pointed out, it's probably best/easiest to use 
the sequence-length variable defined by the dtml-in.

However, if someone just wants a count of records from a db query, and not the
records themselves, then you're right, just use SQL.

Mark
> 
> True enough you could, but why?
> 
> SQL has the correct tools for the job!
> 
> 
> ----- Original Message -----
> From: "Mark N. Gibson" <mark@kaivo.com>
> To: "Sheree Beaudette" <sheree@psouth.net>
> Cc: <zope@zope.org>
> Sent: Wednesday, July 25, 2001 10:16 PM
> Subject: Re: [Zope] Simple, I think!
> 
> 
> > You could do this:
> >
> > <dtml-let results="SQL_Select()">
> > #Results returned = <dtml-var "_.len(results)">
> > </dtml-let>
> >
> > Mark
> >
> > >
> > > I've looked everywhere and I think this should be simple but I'm not
> getting
> > > it
> > >
> > >
> > > I simply want to count the number of records generated by an ZSQL Method
> > > (SQL query) within a DTML Method (something like get the record count of
> > > that certain query).  I then want to refer to this number (could be zero
> if
> > > there are no records) and say if this number is zero then do something,
> else
> > > do something else.
> > >
> > > Can anyone help??
> > >
> > >
> > > _______________________________________________
> > > Zope maillist  -  Zope@zope.org
> > > http://lists.zope.org/mailman/listinfo/zope
> > > **   No cross posts or HTML encoding!  **
> > > (Related lists -
> > >  http://lists.zope.org/mailman/listinfo/zope-announce
> > >  http://lists.zope.org/mailman/listinfo/zope-dev )
> > >
> >
> >
> > _______________________________________________
> > Zope maillist  -  Zope@zope.org
> > http://lists.zope.org/mailman/listinfo/zope
> > **   No cross posts or HTML encoding!  **
> > (Related lists -
> >  http://lists.zope.org/mailman/listinfo/zope-announce
> >  http://lists.zope.org/mailman/listinfo/zope-dev )
>