there is a function called sqlerrm. Have a search coz i don't remember the syntax.