Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

I get following error message when trying to insert an object in the database:

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 can I retrieve the table/column name for which the error is thrown?

like image 953
Mathias G. Avatar asked Jan 04 '17 15:01

Mathias G.


People also ask

How do you view the definition of a table in IBM Db2?

COLUMNS catalog views to view table definitions. For SYSCAT. COLUMNS, each row represents a column defined for a table, view, or nickname. To see the data in the columns, use the SELECT statement.

How do you describe a table structure in Db2?

Tables are logical structure maintained by Database manager. In a table each vertical block called as column (Tuple) and each horizontal block called as row (Entity). The collection of data stored in the form of columns and rows is known as a table. In tables, each column has different data type.


1 Answers

Apparently at the package level, DB2 only works with the IDs and not the 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
like image 98
Mathias G. Avatar answered Sep 28 '22 11:09

Mathias G.