[web2py] Re: Field set the default value +1 on insert

2015-11-21 Thread Bart van Berkel
Hello my friends, Thanks for the inspiration. The answer from Craig, looks to me a good idea how i can do it. many thanks, Bart -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) -

[web2py] Re: Field set the default value +1 on insert

2015-11-17 Thread Craig Matthews
The following is something that I have used in MySQL. MySQL statement: CREATE TABLE IF NOT EXISTS autonumbering ( Year char(4) not null default '', Type varchar(10) not null default '', IDint(11) not null auto_increment, Notes varchar(64) not null

[web2py] Re: Field set the default value +1 on insert

2015-11-11 Thread Massimo Di Pierro
Also you would have to requires the Field('ticket',...,unique=True) because this method it not thread safe and you should be prepared that inserts may fail. On Tuesday, 10 November 2015 11:42:40 UTC-6, Niphlod wrote: > > if you want to have a number that strictly: > > - is incremental (no

[web2py] Re: Field set the default value +1 on insert

2015-11-10 Thread Niphlod
if you want to have a number that strictly: - is incremental (no gaps, always sequential, etc) - the first two digits are the year I'd suggest to have a "last_tickets" table (year(int) , ticket_no(int)) holding the current ticket. then, you can use _before_insert callback on the