[Zope] Iteration over Z SQL Method resultset using fieldnames from TinyTable ??? Cannot figure this...
Petri Savolainen
petri.savolainen@lut.fi
Fri, 19 Nov 1999 02:47:40 +0200
Hello,
I am wondering how do I get an iteration over all the SQL fields that a Z
SQL Method returns- simultaneously picking up the field names from a
Tinytable that same Z SQL Method uses to get the data in the first place?
I've got a SQL Connection to Postgres all set up, a TinyTable containing
fields I want to query, and a Z SQL method called "GetCompanies" containing:
SELECT
<dtml-in QueryFields>
"<dtml-var fieldname>"
<dtml-if sequence-end>
<dtml-else>,
</dtml-if>
</dtml-in>
FROM companies;
In which, fieldname is the variable containing the fieldnames I want, in the
TinyTable. Great this far- it returns a nice table. But- if I want to format
this, by iterating over "GetCompanies" (in a separate DTML Method), and
adding some formatting there, I know just a "hardwired" way, as in:
<dtml-in GetCompanies>
...formatting stuff...
<dtml-var myfieldname>
...more formatting...
</dtml-in>
Because I know "myfieldname" is a name of a database field I know exists,
and thus ends up in the namespace of "GetCompanies", as an attribute
(correct???)
Now, the problem is, what if I want to iterate over the data in
GetCompanies, but don't know any fieldnames, I just know I can get them from
the same old Tinytable??????
Would much appreciate- embarrassingly, I've spent hours trying to figure
this simple thing out... I guess I have to list all that exists in the
namespace of GetCompanies Z SQL Method (all the attributes?), then filter
out the standard stuff ---> what is left is a collection of field names it
has data for??? But how??
Thanks!
Petri