How to show field names from sql query?
Hello all, i use the following to get to show the results from an sql query. What are the expresions to show the field names? <table> <dtml-in expr="TestODBCEM(sysDSN=sysDSN, usr=usr, mypass=mypass, sSQL=sSQL)"> <dtml-if sequence-even> <tr bgcolor="lightgreen"> <dtml-else> <tr> </dtml-if> <dtml-in sequence-item> <td><dtml-var sequence-item></td> </dtml-in> </tr> </dtml-in> </table> Thanks in advance. Thomas. ___________________________________________________________ Χρησιμοποιείτε Yahoo!; Βαρεθήκατε τα ενοχλητικά μηνύματα (spam); Το Yahoo! Mail διαθέτει την καλύτερη δυνατή προστασία κατά των ενοχλητικών μηνυμάτων http://login.yahoo.com/config/mail?.intl=gr
Thomas Apostolou wrote at 2005-9-19 13:43 +0100:
i use the following to get to show the results from an sql query. What are the expresions to show the field names?
The ZSQL method result has a method "names" returning the field names. You can use it in a "dtml-let", similar to: <dtml-let result="TestODBCEM(....)" field_names="result.names()"
<dtml-in result prefix=row> <dtml-in field_names prefix=field> <dtml-var field_item> <!-- the field name --> <dtml-var expr="_[field_item]"> <!-- its value --> .... -- Dieter
Thomas Apostolou wrote:
Hello all, i use the following to get to show the results from an sql query. What are the expresions to show the field names?
<table> <dtml-in expr="TestODBCEM(sysDSN=sysDSN, usr=usr, mypass=mypass, sSQL=sSQL)"> <dtml-if sequence-even> <tr bgcolor="lightgreen"> <dtml-else> <tr> </dtml-if> <dtml-in sequence-item> <td><dtml-var sequence-item></td> </dtml-in> </tr> </dtml-in> </table>
You can ask the Results object 'names()' to get the names of the columns of your results. Note you need to ask the results list, not an individual result, so you'll need to define "TestODBCEM(sysDSN=sysDSN, usr=usr, mypass=mypass, sSQL=sSQL)" as something so as to ask it for names and loop over it later. --jcc -- "Building Websites with Plone" http://plonebook.packtpub.com/ Enfold Systems, LLC http://www.enfoldsystems.com
participants (3)
-
Dieter Maurer -
J Cameron Cooper -
Thomas Apostolou