RE: Incrementing sequence number
Posted in 2000
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL
A lock on the row perhaps? Paul Watson # WFSoftware Ltd # All answers given Tel: +44 1436 674729 # are pure fantasy Fax: +44 1436 678693 # www.wfsoftware.com/informix # -----Original Message----- From: Bytebrothers [mailto:kwillis@dial.pipex.com] Sent: Wednesday, April 19, 2000 3:45 PM To: informix-list@iiug.org Subject: Incrementing sequence number OK, you've all come across this scenario I'm sure, so can someone save me having to reinvent this particular wheel, please? You've got this table which stores, among other things, a name and a sequence number within name: Annie 1 Annie 2 Annie 3 Bob 1 Bob 2 Carol 1 Carol 2 Carol 3 etc Now I need to insert a new row for 'Annie'. I need to select the maximum sequence number currently in use for this name, increment it, and insert my new row with the newly incremented sequence number. How the devil do I do this from ESQLC in an atomic fashion, ie. how do I ensure that no-one reads the max sequence after I have read it but before I have inserted my new row? Sent via Deja.com http://www.deja.com/ Before you buy.
Paul Watson wrote: > A lock on the row perhaps? Obnoxio wrote: > Lock the "max" record? Could the two of you maybe elaborate a little on how to put a lock on a specific row? Regards, Richard -- +--------------------------+------------------------------------------+ | Dr. med Richard Spitz | INTERNET: spitz@ana.med.uni-muenchen.de | | EDV-Gruppe Anaesthesie | Tel : +49-89-7095-6110 | | Klinikum Grosshadern | FAX : +49-89-7095-6420 | | 81366 Munich, Germany | GSM : +49-172-8933578 | +--------------------------+------------------------------------------+