Monday, July 09, 2007

DB2 - Cryptic error messages begone!

Found this on the blog of my friend Lars. I haven't got enough fingers to count the number of times I needed something like this, so I am putting on my own blog as well. :)

A typical cryptic DB2 error message contains something like the following.

Assignment of a NULL value to a NOT NULL column "TBSPACEID=3, TABLEID=14, COLNO=1" is not allowed.

Here is some SQL you can run to determine which table and column such an error is referring to:

SELECT tabschema, tabname, colname
FROM syscat.columns
WHERE colno = XXXX
AND ( tabschema, tabname )
IN (SELECT tabschema, tabname
   FROM syscat.tables
   WHERE tbspaceid = yyyy
   AND tableid = ZZZZ )

Replace XXXX with the column number, YYYY with the table space id and ZZZZ with the table id.

No comments: