Debugging storing SQL statements when the database state changes