Re: Serial (autoincrement) field access
Posted in 1998
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL
Troy, You can use part of the SQL Communication Area Record: sqlca.sqlerrd[2] (in 4GL), sqlca.sqlerrd[1] (in ESQL/C) will return the serial value of the last inserted row. This should save you having to reSELECT the inserted row. Regards. Stuart. ______________________________ Reply Separator ____________________________ _____ Subject: Serial (autoincrement) field access Author: "Troy Peterson" <tp096255@gte.net> at LEND LEASE/LLAP Date: 19/08/98 18:10 I know this sounds dumb, but... I have 3 fields in the primary key for my table and one of them is of 'serial' type. I want to insert a record into this table and then use the auto-assigned serial number from this field in a batch of records for another table. It seems awful sloppy to have to insert the record, run a query to try and find the record I just inserted, and then create my secondary batch of records. In my case this could result in multiple rows being returned and then I'm up a creek. Is there any way I can get my 'insert' to return the value of the autoincrement field? Is there a system variable that can be used? Any light you can shed on this topic would be greatly appreciated.