Re: Serial data types, best way to get back value after insert ESQL/C
Posted in 1996
Rob, The best way is to check the sqlca structure variable "sqlerrd[1]". This integer contains the serial value after an insert. For more info on this, see Chapter 5 (Error Handling with SQLCA", page 5-7 in the Informix Guide to SQL:Reference Dec. 1991. I hope this helps! Tracy ========================================================================= = Tracy W. Nedd = = Banctec Inc. - DBA = = Silver Spring, Md = = tracyn@asd.banctec.com = ========================================================================= = ALL RIGHTS RESERVED. = = This posting is copyright and may be used only for the purposes = = of professional study. Use of this posting in any commercial = = environment is explicity prohibited. This posting may only be = = reproduced for personal archival purposes. = ========================================================================= } } Hi, } what is the best method for getting back the value of a serial data value } in the most recently inserted row using ESQL/C. For example, we are inserting } a row into a table using a serial attribute as the key to that table. After } each successful insert, we may want to update the same row. So we would like } to have the value used by the newly inserted serial attribute. } } Currently, we are using select max(serial_atribute) from .... to determine } the value of the most recent inserted row. However, there seem to be a few } pratfalls. For example, what happens when rows with lower numbers are } removed from the table. Will numbering restart from one ? } } -- } Rob Hale } Software Designer - Nortel Network Services Management } } robert_hale@nortel-nsm.com | When in doubt, } (604) 244 - 4255 | peddle like mad ! } O } /\\_` } _4\\--\\_ } //\\_\\//\\\\ } ____\\_/_ `\\_/______ } }