How to find a table and column in DB2 with the tbspaceid table specified in the error message

When I try to insert an object into the database, I get the following error message:

com.ibm.db2.jcc.am.SqlIntegrityConstraintViolationException: DB2 SQL Error: SQLCODE=-407, SQLSTATE=23502, SQLERRMC=TBSPACEID=2, TABLEID=19, COLNO=0, DRIVER=4.15.134 

How to get the name of the table / column for which an error is thrown?

+4
database db2 tablespace
source share
1 answer

Obviously, at the package level, DB2 only works with identifiers, not names.

You can find them back using the following query:

 SELECT C.TABSCHEMA, C.TABNAME, C.COLNAME FROM SYSCAT.TABLES AS T, SYSCAT.COLUMNS AS C WHERE T.TBSPACEID = 2 AND T.TABLEID = 19 AND C.COLNO = 0 AND C.TABSCHEMA = T.TABSCHEMA AND C.TABNAME = T.TABNAME 
+9
source share

All Articles