SQLCODE: -407, SQLSTATE: 23502: The exact description of this error is such that a NULL value cannot be inserted into a column defined as NOT NULL. This is a violation of the integrity constraint exception.
in development, this error is something that we often encounter. The problem is simply, “Columns that cannot be empty are empty.” For a table with a large number of fields, it is difficult to sift. How to accurately
positioning?It’s actually pretty simple.
We can learn more from the error message, which can help us pinpoint the problem. Common error messages are as follows:
com.ibm.db2.jcc.b.SqlException: DB2 SQL error: SQLCODE: -407, SQLSTATE: 23502, SQLERRMC: TBSPACEID=2, TABLEID=201, COLNO=3
at com.ibm.db2.jcc.b.sf.d(sf.java:1396)
at com.ibm.db2.jcc.c.jb.l(jb.java:356)
at com.ibm.db2.jcc.c.jb.a(jb.java:64)
at com.ibm.db2.jcc.c.w.a(w.java:48)
at com.ibm.db2.jcc.c.dc.c(dc.java:312)
at com.ibm.db2.jcc.b.tf.cb(tf.java:1723)
at com.ibm.db2.jcc.b.tf.d(tf.java:2315)
at com.ibm.db2.jcc.b.tf.Z(tf.java:1326)
at com.ibm.db2.jcc.b.tf.execute(tf.java:1310)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Message: Integrity constraint exception (
--- The error occurred in D:\------- path omitted-------.
--- The error occurred while applying a parameter map.
--- Check the aaa.sql-InlineParameterMap.
--- Check the statement (update failed).
--- Cause: com.ibm.db2.jcc.b.SqlException: DB2 SQL error: SQLCODE: -407, SQLSTATE: 23502, SQLERRMC: TBSPACEID=2, TABLEID=201, COLNO=3)
observe this error message carefully: SQLCODE: -407, SQLSTATE: 23502, SQLERRMC: TBSPACEID=2, TABLEID=201, COLNO=3. You can see that the error message has been located very well
is clear. We only need to query in syscat.columns of the system table. The syscat.columns table is a system table that holds detailed information about the COLUMNS of all tables in a DB2 database. We just need the basis
view, table name, column number can be queried to find which column. COLNO=3 in the error message above is the column number for which the error was reported. As follows:
SELECT
*
FROM
SYSCAT.COLUMNS
WHERE
TABSCHEMA = 'DB' AND
TABNAME = 'TT_PARAM_LOG' AND
COLNO = '3'
Read More:
- [Solved] SQLSTATE[HY000] [2002] Connection refused to report an error when PHP connects to mysql in the docker container
- [Mybatis] How to Solve the problem of Oracle query processing more than 1000 in conditions
- RECEIVED ERROR PACKET: ERRNO = 1236, SQLSTATE = HY000 ERRMSG = COULD NOT FIND FIRST LOG FILE NAME IN BINARY LOG INDEX FILE
- [Solved] mysql -u root -p Error: unable to locate package libncurses.so.5
- [Solved] docker mysql SQLSTATE[HY000] [2002] Connection refused
- How to Check the most CPU consuming 50 queries in MYSQL
- How to Fix MySQL error 1005: can’t create table (errno: 150)
- postgresql-Database query problem-ERROR: column “t.domainid“ must appear in the GROUP BY clause or be used in an a
- mysql workbench Error Code: 1046. No database selected Select the default DB to be used by doubl
- [Solved] EOS7.6 Error: Init DB failed [Specified key was too long; max key length is 767 bytes…
- Dbeaver connects hive to solve the problem that hive custom UDF functions cannot be used in SQL queries in dbeaver
- Mongoose: How to delete all documents in collection
- Introduction to Relational Databases in SQL
- [Solved] flask db init Error: KeyError: ‘migrate‘
- [Solved] Windows MYSQL Error: django.db.utils.OperationalError: (2026, ‘SSL connection error: unknown error number‘)
- [Solved] There is a problem with mysql8.0 without password in Navicat connection
- How to Solve Navicat open view error
- How to Solve c3p0 connect mysql8.0 Error
- How to release Oracle PLSQL data lock table
- How to Solve postgres Errror: ERROR #42883 operator does not exist: smallint ~~ unknown