I've done this with a table with a year as its id:
idb.define_table(
'next_id',
Field('year', 'id'),
Field('next', 'integer'),
)
def get_next_id(year):
record = idb.next_id(year)
if not record:
# Auto add new years
idb.next_id.insert(year=year, next=1)
On Tuesday, January 9, 2018 at 11:03:02 AM UTC-5, Andrea Santini wrote:
>
> i was looking on the net and solved my problem using this code:
>
>
> protocollo_ieri= db(db.protocollo.anno_registro).select().last()
> ieri = protocollo_ieri.anno_registro.year
> data = request.now
> oggi = data.year
>
>
i was looking on the net and solved my problem using this code:
protocollo_ieri= db(db.protocollo.anno_registro).select().last()
ieri = protocollo_ieri.anno_registro.year
data = request.now
oggi = data.year
ultimo_protocollo =
db(db.protocollo).select(db.protocollo.numero_protocollo,orderby=~db
Comments...
1. This kind of auto-incrementing is not bullet-proof in a high traffic
database. Probably better to rely on the DB to compute the field with a
trigger or SP.
2. n_protocol should be an integer field?
3. Virtual fields are not saved to the database. Maybe look at Compute
instead
4 matches
Mail list logo