Improved retrieval of newly assigned primary key in the insert method