Hello,

I have the following table:

 db.define_table("member",
      SQLField("membership_id", "integer",notnull=True),
      SQLField("first_name", "string", notnull=True)
)

and i want  the membership id to be incremented automatically.


the way i used :

 every time i inserted it , i select the max membership_id and adding
one on its value as:

  result=db.executesql("select max(membership_id) from member")
  record=result[0]
  if record[0]:
    next_membership_id = record[0]+1
  else:
     next_membership_id=1
   form.vars.membership_id=next_membership_id

But this solution allows duplicates??

could anyone tell me  what is the perfect solution?


Thanks in Advance



Reply via email to