[Zope] help with dtml and sql---counting database rows with sql method

Dario Lopez-Kästen dario@ita.chalmers.se
Fri, 18 Apr 2003 12:54:27 +0200


----- Original Message -----
From: "Kelley, Sean" <SKelley@ci.santa-rosa.ca.us>
To: <zope@zope.org>
Cc: <sean@horse101.com>
Sent: Friday, April 18, 2003 12:55 AM
Subject: [Zope] help with dtml and sql---counting database rows with sql
method



...snip...


> This query works outside of zope but returns an error that no column name
is
> assigned to the value.  So I name to the resultant column:
>
> SELECT count(*) as p2_count
> FROM IWPLNCHK

Use this query, but call it with <dtml-var counter>. That will give you
access to the value of p2_count, like this (assuming there are 123 records
in the db):

There are <dtml-var counter> records in the database

will give you

There are 123 records in the database


HTH,

/dario