[Zope] Howto convert ZSQL results
Julián Muñoz Domínguez
jmunoz@softhome.net
Fri, 2 Nov 2001 17:35:26 +0000 (GMT)
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 alleged=
ly 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 answ=
er.
> >
> >
> > I get this error:
> >
> >
> > Zope Error
> >
> > Zope has encountered an error while publishing this resour=
ce.
> >
> > 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 its=
elf
> 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
-.-