RE: SELECTing the last value inserted into a SERIAL column
Posted in 1997
Topics: Data Types & Schema Design
} }Hi Clay, } } After Inserting the value into table, Take the value of SQLCA.SQLERRD[2]. }This varable returns the value of SERIAL field which you inserted in the }record. } For detail, refer Informix Manual. } }Thanks, } }Divyesh Patel }Off : 972-461-6435 }email : divyesh_patel@pagenet.com } }---------- }From: Clay Amerault[SMTP:camerault@frankfurtbalkind.com] }Sent: Thursday, June 12, 1997 1:56 PM }To: informix-list@rmy.emory.edu }Subject: SELECTing the last value inserted into a SERIAL column } }I have a table(a) where I want to use a unique number as the primary }key. I had intended on using the data type SERIAL to do this, and }letting the system merely increment it for each INSERT into table(a). }However, I want to be able to capture the SERIAL value that was just }inserted into table(a) so I can insert the value into another table(b). }This would happen in the same transaction as the INSERT into table(a). }Is there a way to retrieve the SERIAL value that was just INSERTed into }table(a)? Or would I be better off using a nextkey table to hold the }next value of the key to be inserted, and basically doing the job of the }SERIAL data type manually? }Thanks. } }-Clay Amerault } }