Hi,
I have created a stored Procedure which inserts multiple records. I am trying to write exception handling which also reports on the field value which is duplicated.
PROCEDURE MYPROC ( ) AS BEGIN declare j varchar(20) := 25; DECLARE EXIT HANDLER FOR SQLEXCEPTION INSERT INTO MyErrorTable values (::SQL_ERROR_CODE, ::SQL_ERROR_MESSAGE, :j); j := :j + 1; INSERT INTO MyTable values (:j,'A','A','A','A'); j := :j + 1; INSERT INTO MyTable values (:j,'B','B','B','B'); INSERT INTO MyTable values (:j,'B','B','B','B'); j := :j + 1; INSERT INTO MyTable values (:j,'C','C','C','C'); END;
MyTable has the first column as key field which is Integer. In the above code, the 3rd insert statement will fail as there would be a unique constraint violated. I would like to know how we can capture that value into the Error Table.
When I run the above procedure the value of J is always 25 in the errorTable.
Thanks,
Murali.