Updated SQL-error-function