Deciphering DB2 error messages

Filed under: Development — lars @ 03:04:47 pm

DB2 SQL errors are so typical of errors in IBM products - enigmatic and unhelpful. I recently found out that there's an SQL query you can run to determine which table and column an error (like the one below) is referring to:

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

This magical SQL is:

SELECT tabschema, tabname, colname FROM syscat.columns
WHERE colno = 1 AND ( tabschema, tabname ) IN
( SELECT tabschema, tabname FROM syscat.tables WHERE tbspaceid = 3 AND tableid = 14 )

Just sub in the tablespace, table and column IDs from your error message, and you're away.

Comments

Leave a comment

Allowed XHTML tags: <p, ul, ol, li, dl, dt, dd, address, blockquote, ins, del, span, bdo, br, em, strong, dfn, code, samp, kdb, var, cite, abbr, acronym, q, sub, sup, tt, i, b, big, small>


Options:
(Line breaks become <br />)
(Set cookies for name, email & url)




powered by  b2evolution