RE: Serial (autoincrement) field access
Posted in 1998
David Ashby wrote: Troy, > > Have a look in the 4GL manual under the heading of SERIAL. You should > find a subheading for SQLCA.SQLERRD[2]. This variable is set with the > value of the inserted serial column. > > By the way your right it is dumb to have more than the necessary columns > as the key to a row than is necessary to uniquely identify it. You are > heading down the road of disaster (opinion only). > > > Regards > David Ashby You should also check out DBINFO('sqlca.sqlerrd1'), if you're planning to use this in an SPL or trigger etc (vers 7.x). I agree with David, surely your PK should be the other two columns without the SERIAL value ? cheers RET > > -----Original Message----- > From: Troy Peterson [mailto:tp096255@gte.net] > Sent: Thursday, 20 August 1998 4:10 > To: informix-list@iiug.org > Subject: Serial (autoincrement) field access > > 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. > >