exception handling in sql_prepare