posted 21 years ago
How to get the primary key is most likely implementation specific. You can disable autogenerated primary keys for a table and insert your own primary key. Then you know what the primary key will be before you insert it. This method is cross-database, gives you more control, but is slightly more work to implement.
If your primary key is autogenerated you can 1) use vendor specific syntax to return the last inserted primary key like @@identity in TransactSQL or 2) use a select statement based on a 'date_added' column with other values just inserted.
Then set the primary key of your value object and return that.