[Zope-DB] Counting hits

kapil thangavelu kthangavelu@earthlink.net
Fri, 16 Aug 2002 10:22:26 -0700


On Friday 16 August 2002 06:59 am, Jon Erickson wrote:
> On Fri, 2002-08-16 at 08:14, Smith, Neil wrote:
> > Is it possible to get the number of records that are returned by a select
> > in a ZSQL method?  I'm using DCOracle2.  Ideally I would like to avoid
> > having to do a second ZSQL method with a "select count(*)" in it.
>
> No, ZSQL methods are not able to report the number of rows returned
> which kinda stinks.  If your using python to process the ZSQL method you
> could:
>
> results = container.zsql_method()
> num_rows = len(results)
>
> Performing a len() function on the results object returned by zsql
> methods will give you the number of rows returned.  However, this
> example is not practical if your using DTML or ZPT to process the ZSQL
> method.
>

not practical but possible ;-)

<dtml-let foo=zsql_method>
<dtml-var "_.len(foo)"> Results
   <dtml-in foo>
    blahh
   </dmtl-in>
</dtml-let>

-k