Below is the dtml code for a DTML document I have written
to return the results of any SQL query as an html table in groups of 50. 

Query.QuickSQL() takes as an argument a complete SQL statement.
"sqlStatement" is the REQUEST variable with the SQL statement.

 You can replace the query with your own ZSQL query.

getRes is an external python method, here it is:
def getRes(self, zQry) :
    tvar1 = 'res=self.'+zQry
    exec tvar1
    return tc1
this came out of a function module I wrote
that has all the imports at the top. You may
need to "import sys" for this to work. I don not
              Jim Sanford
      .       Database Engineer
     / \  /   Accelerated Technology, Inc.
    /   /     720 Oak Circle Drive East
   /  /  \    Mobile, AL 36609
  / /     \   Voice: 334-661-5770  fax: 334-661-5788
 /         \  E-Mail: [EMAIL PROTECTED]
 Nucleus.  All You NEED in an RTOS.  Royalty Free

DTML Document Code below
<dtml-var sqlStatement><br><br>
<dtml-with "_.namespace(t1=getRes('Query.QuickSQL()'), t2=Query.QuickSQL())">
<dtml-call "REQUEST.set('colList',[])">
<dtml-in t1>
<dtml-call "colList.append([_['sequence-item'],_['sequence-key']])">
<dtml-call "colList.sort()">
<dtml-in t2 size=50 start=query_start>
<dtml-if sequence-start>
<dtml-if previous-sequence>
<a href="<dtml-var URL><dtml-var sequence-query
>query_start=<dtml-var previous-sequence-start-number>">
(Previous <dtml-var previous-sequence-size> results)
</dtml-if previous-sequence>
  <table border=1>
  <dtml-in colList>
  <dtml-let tlist="_['sequence-item']"
  <th><dtml-var tname html_quote></th>
<dtml-let titem="_['sequence-item']">
<dtml-in colList>
<dtml-let tlist="_['sequence-item']"
<td><dtml-var "titem[tcol]" html_quote newline_to_br></td>
<dtml-if sequence-end>
<dtml-if next-sequence>
<a href="<dtml-var URL><dtml-var sequence-query
(Next <dtml-var next-sequence-size> results)
</dtml-if next-sequence>
</dtml-if sequence-end>

Zope maillist  -  [EMAIL PROTECTED]
**   No cross posts or HTML encoding!  **
(Related lists - )

Reply via email to