Thursday, July 07, 2011

Decoding IBM DB2 error message

Ever get an IBM DB2 error message like "SQL0407N Assignment of a NULL value to a NOT NULL column TBSPACEID=n1, TABLEID=n2, COLNO=n3 is not allowed. What actually does "TBSPACEID=n1, TABLEID=n2, COLNO=n3" mean? Don't ask me, you should ask IBM DB2, but how?

SELECT C.TABSCHEMA, C.TABNAME,
C.COLNAME
FROM SYSCAT.TABLES AS T,
SYSCAT.COLUMNS AS C
WHERE T.TBSPACEID = n1
AND T.TABLEID = n2
AND C.COLNO = n3
AND C.TABSCHEMA = T.TABSCHEMA
AND C.TABNAME = T.TABNAME