[Zope] calling ZSQL "in place"

Jens Vagelpohl tommymi@concentric.net
Wed, 5 Jan 2000 00:13:03 -0500


hi tim,

first of all, <dtml-call> will not return any data per se. it will call the
method but ignore data returned.

as with any ZSQL query you devise, what you get back is a set of records.
this means the way to retrieve data is the <dtml-in> tag, which is used to
iterate over records. here's some (tested on oracle8) example code:

ZSQL method called count_sql:

select count(*) as num_count from <tablename>

the result is being displayed in a dtml-document or method as follows:

There are <dtml-in count_sql>
            <dtml-var num_count>
          </dtml-in> records in the database.

hth

jens



> -----Original Message-----
> From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of
> Timothy Wilson
> Sent: Tuesday, January 04, 2000 23:45
> To: Zope listserv
> Subject: [Zope] calling ZSQL "in place"
>
>
> Hi everyone,
>
> I'd like to print the total number of records in a database table and
> print that number on my page. My ZSQL method looks like:
>
> SELECT COUNT(*) FROM foo_table
>
> The method returns the correct number when I test it.
>
> I'd like to print the following:
>
> There are [insert SQL result here] records in the database.
>
> Using <dtml-call "foo_sql(REQUEST)"> doesn't work. Ideas?
>
> BTW, I've very impressed with the SQL tools that Zope has. Obviously, I'm
> new to using SQL with Zope, but the Z Search Interface Wizard was an
> absolute God-send. I'd be nowhere near as far along as I am without it.
>
> Now if I could just find my Zen... :-)
>
> -Tim