Stored procedures and exceptions
Posted in 1996
I'm relatively experienced in ESQL/C but have recently started dabbling in stored procedures. The problem I have is as follows: ............ IF (<condition>) THEN RAISE EXCEPTION <SQL status code> END IF ............ The above code works fine when the SP is called from ESQL. However, I need to return a meaningful text message from the SP. So what I've done is: ............ ON EXCEPTION IN (<SQL status code>) return errMessage; END EXCEPTION ............ IF (<condition>) THEN LET errMessage = "<A descriptive error message !!> RAISE EXCEPTION <SQL status code> END IF ............ Works fine except that the error status is cleared by the ON EXCEPTION clause and so making my SQLCODE check in C redundant. Finally to the point. What I want to know is: How do I set SQLCODE (or its equivalent within SPL) so that all I have to check in C is the SQLCODE. I don't want to have to set the errMessage to NULL and check it later as this is a rather clumsy method. I apologise for any syntactical errors above. All ideas welcome, Pete Test singature !