Fix bug insert and update to DB.