[Zope-DB] max(<fieldname>)

Matthew T. Kromer matt@zope.com
Mon, 29 Oct 2001 07:30:10 -0500


On Monday, October 29, 2001, at 06:41 AM, Hout, Eric van den wrote:

> Hi,
>
> Can anyone tell me why this:
>    select nw_id from nieuws
> does work and this:
>    select max(nw_id) from nieuws
> does not?
>
> What I am trying to do on a Gadfly DB is to make a primary key "auto"
> incremental.
>
> Anyone knows some info on how to achieve this? The book and the gadfly 
> docs
> trell how to create a unique index, but I can't find out how to use 
> this to
> "auto create" my Primary key.
>
> Help?
>

Hi Eric,

I'm not sure that Gadfly supports any kind of automatic unique key 
generation BUT, I can suggest why your MAX(nw_id) fails.  When you 
select something from a Database Adapter, zope tries to name it the same 
way the result comes back -- in this case as MAX(nw_id) --  so instead, 
if you

select MAX(nw_id) as nw_id from nieuws

it should work...