[Zope] How to show field names from sql query?

J Cameron Cooper zope-l at jcameroncooper.com
Tue Sep 20 16:57:54 EDT 2005


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


More information about the Zope mailing list