Subject | Returning the Primary Key value of a new row added by a stored procedure? |
---|---|
Author | mlq97 |
Post date | 2007-08-10T18:49Z |
Is there a 100% reliable way of returning the primary key value of a
new row added by a stored procedure?
My procedure adds a row (which gets an auto generated PK ID) and then
needs the PK ID to do further processing. The temporary method that I
am using involves using a datestamp variable and inputting this during
row insert. Once the row is inserted I select for the row with that
timestamp to find the ID.
This seems inelegant and the row datestamp is not guaranteed to be
unique. Is there a better way?
Many thanks,
Mitch
new row added by a stored procedure?
My procedure adds a row (which gets an auto generated PK ID) and then
needs the PK ID to do further processing. The temporary method that I
am using involves using a datestamp variable and inputting this during
row insert. Once the row is inserted I select for the row with that
timestamp to find the ID.
This seems inelegant and the row datestamp is not guaranteed to be
unique. Is there a better way?
Many thanks,
Mitch