Hi,
using DB2 v9.5 fixpack 2a on Linux I have several SQL statements in single stored procedure. But when I get an error I don't know which SQL in stored procedure returned error. Is there any way I can get info which SQL inside stored procedure returned error?
Bellow simple sample:
Code:
CREATE TABLE ADMIN.TAB1 (A INT)@
CREATE TABLE ADMIN.TAB2 (A INT NOT NULL)@
CREATE PROCEDURE ADMIN.STORED_PROCEDURE
LANGUAGE SQL
BEGIN ATOMIC
INSERT INTO ADMIN.TAB1 (A) VALUES (1);
INSERT INTO ADMIN.TAB2 (A) SELECT A FROM ADMIN.TAB1;
END@
-- Stored procedure executes without error.
CALL ADMIN.STORED_PROCEDURE@
-- Now I will intentionally insert a null value and I know the
-- error should be produce by second SQL, because definition
-- of tab2 column A is defined as not null.
INSERT INTO ADMIN.TAB1 VALUES (NULL)@
-- Calling stored procedure
CALL ADMIN.STORED_PROCEDURE@
-- Above command produces error like expected:
SQL0407N Assignment of a NULL value to a NOT NULL column "TBSPACEID=2,
TABLEID=1663, COLNO=0" is not allowed. SQLSTATE=23502
This is simple sample, I know from sample above that second SQL produced error, but is there any way I can get info: "SQL 2 produced error"?
This is simple sample and is very easy to find out which SQL produces error, but if I have 20 or more SQLs in stored procedure it is time consuming to execute each SQL in stored procedure to find out which SQL produced error.
How to find which SQL from stored procedure has return error message?
Thanks