Allow the return of InsertId directly after insert or update

This fixes issue  #866.