help with dtml and sql---counting database rows with sql method
Hi, I am trying to count database rows in a table by using the following call to the sql method: <dtml-call counter> In my counter zsql method I pass in no parameters. My sql script is: SELECT count(*) FROM IWPLNCHK 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 which work in an sql test in zope but still does not output the count value to the calling page. How do I pass this value back and display it? thanks, Sean
----- 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
Thanks- I tried this and get the error: <Shared.DC.ZRDB.Results.Results instance at 0x9fc69cc> Any ideas what this means? Dario Lopez-Kästen wrote:
----- 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
participants (3)
-
Dario Lopez-Kästen -
Kelley, Sean -
Sean Kelley