print results from a datrabase query
I am trying to query a field in a database then print the output in both an email and an html file. It looks like I am getting the memory address of the Z SQL method instead of the value returned by the query. -Thanks in advance --------------------------- Called from the input form: --------------------------- "processTicket" method <dtml-call newTicket> # "newTicket" makes an entry to a MySQL database with the users input from the form. <dtml-call maxTicketNumQuery> # "maxTicketNumQuery" gets the MAX from the database. (see below) <body bgcolor=white> <dtml-sendmail mailhost="mailhost"> To:<dtml-var webmaster> From:<dtml-var email> Subject: Trouble Ticket A Trouble Ticket was submitted by <dtml-var name> at <dtml-var ZopeTime>. Ticket Number <dtml-var maxTicketNumQuery> (I don't think this part is right. I tried to <dtml-call maxTicketNumQuery> but that didn't work either) Description of Problem: <dtml-var problem> </dtml-sendmail> <dtml-var standard_html_header> <p> Thank you <dtml-var name>. An E-Mail will be sent to you soon for reference. Your ticket number is <dtml-var maxTicketNumQuery>. <p> Someone will be in contact with you soon. <p> To return to the main page, click logo. ----------------------------------- Called from "processTicket" method: ----------------------------------- "maxTicketNumQuery" Z SQL method: select MAX(ticketNum) from ticket3 # called from "processTicket" method. I am trying to get the results of the "ticketNum" filed in the database. I DO NOT have "ticketNum" defined as an argument in the Z SQL method. I'm not sure if it should be. Either way, I get the same error. This is the output from the email that is sent once a ticket has been entered. ------------------------------------------------- A Trouble Ticket was submitted by Foo Man Chew at 2001/07/10 15:53:24.7536 GMT-4. Ticket Number <Shared.DC.ZRDB.Results.Results instance at 8728218> Description of Problem: server crash --------------------------------------------------- Instead of the <Shared.DC*> output, I would like the result of the "maxTicketNumQuery", which should be an integer value like 29. Also, I have read most of the Zope book. It's a little over my head. Can anyone point me to a Zope database document written at the beginner level? __________________________________________________ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail http://personal.mail.yahoo.com/
Terry McKenna writes:
I am trying to query a field in a database then print the output in both an email and an html file.
It looks like I am getting the memory address of the Z SQL method instead of the value returned by the query. ... <dtml-var maxTicketNumQuery> You get a "Shared.DC.ZRDB.Results.Results" object. It behaves like a list of rows representing your query result. Each row behave like an object the attributes of which are the columns of your query.
Use something like: <dtml-let ticket=maxTicketNumQuery> <!-- this calls your method! --> .... <dtml-var "ticket[0].NUM"> <!-- assumed: select max(*) as NUM ... --> .... </dtml-let> Dieter
participants (2)
-
Dieter Maurer -
Terry McKenna