Julián Muñoz Domínguez wrote:
How to convert to integer the the result of a ZSLQ method ??
I call a ZSQL method with: l=int(container.last_customer())
The field I query is has the type "VARCHAR(10) with Null" I am doing this query through ZODBC DA, to an Access .mdb file.
I am digging many hours in the Documentation, and doesn't find the answer.
I get this error:
Zope Error
Zope has encountered an error while publishing this resource.
Error Type: AttributeError Error Value: DatabaseResults instance has no attribute '__int__'
Julián: A ZSQL Method like last_customer() returns a DatabaseResults object, which has a list of records from your database. If you are really sure that it is an integer in the first field of the first row of the result, you can: l=int(container.last_customer()[0][0]) This gets the first field of the first row of your ZSQL Method results, and converts it to an int. I would maybe do it like this (ymmv): t = container.last_customer()[0][0] if t is not None: l = int(t) else: l = 0 -- Jim Washington