Hi All,
I'm trying to insert a row in table. I have to raise and exception if for any reason(s) insert operation fails. I'm trying to achieve this by using SQLCODE and SIGNAL SQLSTATE but am getting an error. Here's the code that I'm trying to compile :
INSERT INTO audit_row
(raid, table_name, rid, action, action_date, userid)
VALUES
(raid, tabname, erid, act, CURRENT TIMESTAMP, NULL);
-- Return a scary message if for some reason the statement failed.
IF(SQLCODE = 100)
THEN
SIGNAL SQLSTATE '02000'
SET MESSAGE_TEXT = 'Error creating Row Audit record. Contact DBA';
END IF;
On compiling the procedure I get an error - SQL0206N "SQLCODE" is not valid in the context where it is used.
Could some one please help me in understanding why "SQLCODE" is not valid in this context and how can I raise an exception in the above stated case !
Regards,
Ekta
DB2 & UDB email list listserv db2-l LazyDBA home page