Q: How do you enumerate and display the field NAMES in a SQL result set? Suppose you have a ZSQLMethod, getSightings (from Lesson 11 in the Zope Tutorial). What I'd like to do is enumerating the fields in the results of this query to display the field names (without knowing them). Here's what I tried, but it doesn't work (in particular, note the sequence-start block): <dtml-var standard_html_header> <h2><dtml-var title></h2> <table border=1> <dtml-in getSightings> <dtml-if sequence-start> <tr> <dtml-in sequence-item> <td><dtml-var sequence-key></td> </dtml-in> </tr> </dtml-if> <tr> <dtml-in sequence-item> <td><dtml-var sequence-item></td></dtml-in> </tr> <dtml-comment> <p><dtml-var date> -- <dtml-var location></p> <p>Reported by <dtml-var name></p> <p><dtml-var description></p> </dtml-comment> </dtml-in> </table> <dtml-var standard_html_footer> Any ideas? Thanks, Mark __________________________________________________ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail - only $35 a year! http://personal.mail.yahoo.com/
Mark McEahern writes:
Q: How do you enumerate and display the field NAMES in a SQL result set? You search the (searchable) mailing list archive ...
"Shared.DC.ZRDB.Result.Result" instances (thats what you get from a Z SQL method (if it is a search)) have a "names" method that return the column names. Dieter
[Mark McEahern]
Q: How do you enumerate and display the field NAMES in a SQL result set?
As Dieter said, it's been answered here before. Here is a copy of one of my posts about this: =================================================== I remember posting this before, but something seems to have eaten it. Laurie Nason nailed it for me, many thanks Laurie. Here is a summary of the result: Given a ZSQL query named "query1", this DTML will execute the query and display a list of the column names: <dtml-let results=query1> <dtml-var "results.names()"> </dtml-let> And here it is using dtml-with: <dtml-with query1> <dtml-var "names()"> </dtml-with> Thanks to all for the help. Regards, Tom P
participants (3)
-
Dieter Maurer -
Mark McEahern -
Thomas B. Passin