thanks for help
--
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to web2py+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/web2py?hl=en.
On Jan 15, 10:32 am, Thadeus Burgess <thade...@thadeusb.com> wrote:
> Field('mysecondaryid', 'integer', default=db.table.mysecondaryid + 1)
>
> should work.
>
> -Thadeus
>
> On Fri, Jan 15, 2010 at 7:14 AM, Alexandre Andrade <alexandrema...@gmail.com
>
> > wrote:
> > by default, web2py creates a 'id' field, it is autoincremented.
>
> > 2010/1/15 ceriox <cer...@gmail.com>
>
> >> hi all,
> >> i need an autoincremented unic numeric field for make a ticket system
> >> how i can do it?
>
> >> thanks for help
>
> >> --
>
> >> You received this message because you are subscribed to the Google Groups
> >> "web2py-users" group.
> >> To post to this group, send email to web...@googlegroups.com.
> >> To unsubscribe from this group, send email to
> >> web2py+un...@googlegroups.com<web2py%2Bunsu...@googlegroups.com>
> >> .
> >> For more options, visit this group at
> >>http://groups.google.com/group/web2py?hl=en.
>
> > --
> > Atenciosamente
>
> > --
> > =========================
> > Alexandre Andrade
> > Hipercenter.com
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "web2py-users" group.
> > To post to this group, send email to web...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > web2py+un...@googlegroups.com<web2py%2Bunsu...@googlegroups.com>
To unsubscribe from this group, send email to web2py+un...@googlegroups.com.
db.table.autonumber.default = max_id + 1 # Set the table default as
the last autonumber and incremented by one.
db.table.autonumber.writable = False
form = crud.create(db.table)
-Thadeus
I thought that autoincremented field would guaranty unicity in the
table.
I'm afraid the provided solution would allow two record to have the
same autonumber field (think about an access from two users at the
same time).
I guess the autoincrement should be done on the DAL or database side,
inside a transaction....
What do you think about it ?
definet_table('sometable',
Field('otherid', compute=lambda r: r['id'])
)
Field('otherid','string', compute=lambda r: 'SOMETHING%s%s' % (
str(datetime.date.today()),
str(r['id'])))
>> > > web2py+un...@googlegroups.com<web2py%2Bunsubscribe@googlegroups.com>
>> > > web2py+un...@googlegroups.com<web2py%2Bunsubscribe@googlegroups.com>
> > web2py+un...@googlegroups.com<web2py%2Bunsubscribe@googlegroups.com>
import datetime
db.define_table('sometable',
Field('otherid',
compute=lambda r: 'SPPRIME%s' % (
datetime.date.today().strftime('%y%m%d'))
)
current.db.sometable.insert()
otherid==None :(