Hi All Thank you for the helpful comments! I am fine leaving the SQL Execute statement in place, but thought the question was worth asking.
-Rob On Tuesday, May 25, 2021 at 8:06:46 AM UTC-4 Carlos Correia wrote: > Às 18:20 de 20/05/21, Rob Paire escreveu: > > Hello all, > > I am wondering if it's possible to use DAL update method to increment the > value of table column H_REVNO in one line of code, and one trip to the > database? > > I tried this query, and a couple of similar variations, but could not get > it to work. > db(db.KICKER.id == request.vars.kicker_id).update(H_REVNO=H_REVNO+1) > > Here is what I am using for now > db.executesql("update KICKER set H_REVNO = H_REVNO + 1 where ID = "+ > str(request.vars.kicker_id)) which of course works. > > Thank you all! > > > > Hi, > > Using DAL you have to read the record first in other to get the value to > be incremented. But, if there are many users it might lead to corrupted > values due to concurrency. > > As far as I know, the latest is the only sane approach to solve your > problem. > > > Carlos Correia > ========================= > MEMÓRIA PERSISTENTE > GSM: 917 157 146 (Signal, WhatsApp) > e-mail: ge...@memoriapersistente.pt > URL: http://www.memoriapersistente.pt > XMPP (Jabber): car...@memoriapersistente.pt > GnuPG: wwwkeys.eu.pgp.net > > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/a13396f4-3a22-4705-88e5-f5b48a2c3e80n%40googlegroups.com.