Hi there, I hope this is going to the right forum - if not, my apologies. :-) I'm hoping that this is a fairly simple question to be answered - I'm fairly new to Zope and am only a novice programmer at best :-) I am running a MySQL query (Find_Last_Callnote) which looks like this - select max(CALLNOTENUM) from callnote where JOBID = '<dtml-sqlvar JobID type="int">' so basically I'm trying to get the maximum value in field CALLNOTENUM given a specific jobID. This all works fine however what I want to do then is increment the last CALLNOTENUM by 1 and then add a new callnote with that number So my DTML Method looks something like this except I have left out the bit where I would have to increment the number by 1 and then call the update function - <dtml-in Find_Last_Callnote> <dtml-if max(CALLNOTENUM)> <p>This is not the first callnote</p> ?????? WHAT DO I DO HERE ?????? <dtml-else> <p>This is the first callnote</p> <dtml-call Insert_First_Callnote> </dtml-if> </dtml-in> Unfortunately when using SQL functions such as 'max' the dtml variables assigned come back which Brackets in them - this means that if I try to do a <dtml-if expr="max(CALLNOTENUM etc.)"> the dtml is not interpreted correctly and results in an error. I assume I might have write a python script to pull this off, is that true? and if so how would I do that. Of course I'm probably trying to do this the hard way, so if there is an easier way could you let me know? :-) Many thanks, Michael
Hello Michael, Change your select statement a little bit and adjust your DTML method: select max(CALLNOTENUM) as theMaximum from callnote where JOBID = '<dtml-sqlvar JobID type="int">' and adjust the DTML method: <dtml-in Find_Last_Callnote> <dtml-if theMaximum> We have a Maximum: <dtml-var theMaximum> <dtml-let theMaximum="theMaximum+1"> New Maximum: <dtml-var theMaximum> </dtml-let> <dtml-else> We have no Maximum </dtml-if> </dtml-in> G'day Arno On Sat, 09 Jun 2001, Michael Billimoria wrote:
I am running a MySQL query (Find_Last_Callnote) which looks like this -
select max(CALLNOTENUM) from callnote where JOBID = '<dtml-sqlvar JobID type="int">'
so basically I'm trying to get the maximum value in field CALLNOTENUM given a specific jobID.
This all works fine however what I want to do then is increment the last CALLNOTENUM by 1 and then add a new callnote with that number
So my DTML Method looks something like this except I have left out the bit where I would have to increment the number by 1 and then call the update function -
<dtml-in Find_Last_Callnote>
<dtml-if max(CALLNOTENUM)> <p>This is not the first callnote</p> ?????? WHAT DO I DO HERE ?????? <dtml-else> <p>This is the first callnote</p> <dtml-call Insert_First_Callnote> </dtml-if>
</dtml-in>
Unfortunately when using SQL functions such as 'max' the dtml variables assigned come back which Brackets in them - this means that if I try to do a <dtml-if expr="max(CALLNOTENUM etc.)"> the dtml is not interpreted correctly and results in an error.
I assume I might have write a python script to pull this off, is that true? and if so how would I do that. Of course I'm probably trying to do this the hard way, so if there is an easier way could you let me know? :-)
Many thanks,
Michael
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
participants (2)
-
Arno Gross -
Michael Billimoria