Add an assert() to verify the last-row-id for the database just prior to calling a SQL function.