[web2py] Re: Get last inserted field value

2011-06-05 Thread Massimo Di Pierro
Also no-transactions (except for explicit record level transactions), no OR in joins, not joins, not select(distinct=True), no select(having=...). These are all GAE limitations. On Jun 5, 4:47 am, Phyo Arkar wrote: > Finally Here is what i found after an hr of digging web2py group: > > fmax=db.ta

Re: [web2py] Re: Get last inserted field value

2011-06-05 Thread Phyo Arkar
Finally Here is what i found after an hr of digging web2py group: fmax=db.table.field.max(), fmin=db.table.field.min() fcount=db.table.field.count() fsum=db.table.field.sum()) rows = db(query).select(fmax,fmin,fcount,fsum) vmax=rows[0][fmax] vmin=rows[0][fmin] vavg=rows[0][fsum]/(rows[0][fcount] o

Re: [web2py] Re: Get last inserted field value

2011-06-05 Thread Phyo Arkar
I am also needing to find out max value of a field , seems like it is undocumented. Is it exist? Where in api doc should i look for. On 4/4/11, Anthony wrote: > On Monday, April 4, 2011 9:39:31 AM UTC-4, Neveen Adel wrote: >> >> Thanks a lot Massimo :) >> >> The problem with this solution is th

[web2py] Re: Get last inserted field value

2011-04-04 Thread Anthony
On Monday, April 4, 2011 9:39:31 AM UTC-4, Neveen Adel wrote: > > Thanks a lot Massimo :) > > The problem with this solution is that i have a table has member_id as > foreign key and by this solution that data will be lost. Are you saying in the legacy database, the 'member' table has a 'me

[web2py] Re: Get last inserted field value

2011-04-04 Thread Neveen Adel
Thanks a lot all of you for your help :) Am thinking to make the default value of membership_id equal to id and by that duplicates will never occurred and also am not need to remove id column. Thanks again for ur help :) On Apr 4, 3:44 pm, Ross Peoples wrote: > Massimo's idea would work, but

[web2py] Re: Get last inserted field value

2011-04-04 Thread Ross Peoples
Massimo's idea would work, but the table would need to have "membership_id" set up as an identity field. If your existing structure requires you to manually fill in this value yourself, then you would have to do your inserts manually using executesql: db.executesql("INSERT INTO member (membersh

[web2py] Re: Get last inserted field value

2011-04-04 Thread Neveen Adel
Thanks a lot Massimo :) The problem with this solution is that i have a table has member_id as foreign key and by this solution that data will be lost. so i searched for a solution on controller level. Thanks On Apr 4, 3:31 pm, Massimo Di Pierro wrote: > how about > > db.define_table("member"

[web2py] Re: Get last inserted field value

2011-04-04 Thread Massimo Di Pierro
how about db.define_table("member", SQLField("membership_id", "id"), SQLField("first_name", "string", notnull=True) ) and "membership_id" would be your "id" field? On Apr 4, 8:03 am, Neveen Adel wrote: > Thanks Anthony for your reply. > > The table already have an old data so i can'

[web2py] Re: Get last inserted field value

2011-04-04 Thread Neveen Adel
Thanks Anthony for your reply. The table already have an old data so i can't remove the column id or change in the database structure. Is there another solution in controller level not database level? Thanks in Advance On Apr 4, 2:54 pm, Anthony wrote: > Your table already includes an 'id' fie

[web2py] Re: Get last inserted field value

2011-04-04 Thread Anthony
Your table already includes an 'id' field by default, which is an auto-increment integer field starting at 1. Why do you need a separate 'membership_id' field? If it's a legacy database and you need the name of the 'id' field to be 'membership_id', you can simply define the field type as 'id' (