Re: [Zope] Howto convert ZSQL results
Thanks a lot !!! The query I am doing is: select MAX(CliCodigo) from ClientesTabla And the column that is returned by zope is named 'Expr1000' (a bit strange :-)), and doing: I=int(container.last_customer()[0].Expr1000) Works !!! Thank you, I was becoming fool :-) On Fri, 2 Nov 2001, Casey Duncan wrote:
On Friday 02 November 2001 11:21 am, Julián Muñoz Domínguez allegedly 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__'
It sounds like you are trying to convert the whole row or recordset to an int, which obviously won't work. You need to return just the field by itself like:
I=int(container.last_customer().name_of_field)
or possibly:
I=int(container.last_customer()[0].name_of_field)
hth, /---------------------------------------------------\ Casey Duncan, Sr. Web Developer National Legal Aid and Defender Association c.duncan@nlada.org \---------------------------------------------------/
-- __o _ \<_ (_)/(_) Saludos de Julián EA4ACL -.-
On 2/11/01 5:35 pm, "Julián Muñoz Domínguez" <jmunoz@softhome.net> wrote:
Thanks a lot !!!
The query I am doing is: select MAX(CliCodigo) from ClientesTabla
And the column that is returned by zope is named 'Expr1000' (a bit strange :-)), and doing:
I=int(container.last_customer()[0].Expr1000)
Works !!! Thank you, I was becoming fool :-)
If you rewrite the SQL as; select MAX(CliCodigo) as max_clicodigo from ClientesTabla (this is an SQL-alias basically) You'll get a variable called mac_clicodigo which you can use. hth Tone. -- Dr Tony McDonald, Assistant Director, FMCC, http://www.fmcc.org.uk/ The Medical School, Newcastle University Tel: +44 191 243 6140 A Zope list for UK HE/FE http://www.fmcc.org.uk/mailman/listinfo/zope
participants (2)
-
Julián Muñoz Domínguez -
Tony McDonald