Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Db2 human readable error formatter

Almost all clients for DB2 return errors in format

Error: DB2 SQL Error: SQLCODE=-407, SQLSTATE=23502, SQLERRMC=TBSPACEID=2, TABLEID=103, COLNO=0, DRIVER=3.57.82
SQLState:  23502
ErrorCode: -407

Than I should google for SQLCODE, than for SQLState and then try to understand meaning of SQLERRMC. It is time consuming... I would like to know is there tool which parse such format and return human friendly formatted error, such as "You are tring to insert null in position 2 where only non null values posible..."

like image 708
yura Avatar asked Nov 04 '11 10:11

yura


1 Answers

To convert 'SQLERRMC=TBSPACEID=x, TABLEID=y, COLNO=z' to schema, table and column names, at a SQL prompt:

SELECT C.TABSCHEMA, C.TABNAME, C.COLNAME
FROM SYSCAT.TABLES AS T,
SYSCAT.COLUMNS AS C
WHERE T.TBSPACEID = x
AND T.TABLEID = y
AND C.COLNO = z
AND C.TABSCHEMA = T.TABSCHEMA
AND C.TABNAME = T.TABNAME

Credit: I found this at http://www.dbforums.com/db2/1655517-how-find-table-tbspaceid-2-tableid-1583-a.html

like image 77
user598656 Avatar answered Oct 02 '22 23:10

user598656