java 如何解决 DB2 SQL 错误:SQLCODE=-407,SQLSTATE=23502
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32283155/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to solve DB2 SQL Error: SQLCODE=-407, SQLSTATE=23502
提问by Jayapraksh
2015-08-28 18:12:19.047-Fri Aug 28 18:12:19 IST 2015DB2 Connection established -->com.ibm.db2.jcc.t4.b@c26e4a
2015-08-28 18:12:20.030-Execution failed ======> alter table BLP.COUNTER_EXTRACTION_REQUEST alter column SCHEME_ID set not null
2015-08-28 18:12:20.032-Error code for failure ======> DB2 SQL Error: SQLCODE=-407, SQLSTATE=23502, SQLERRMC=SCHEME_ID, DRIVER=3.63.123
2015-08-28 18:12:20.044-Execution failed ======> alter table BLP.COUNTER_EXTRACTION_REQUEST alter column SCHEME_TYPE set not null
2015-08-28 18:12:20.044-Error code for failure ======> DB2 SQL Error: SQLCODE=-407, SQLSTATE=23502, SQLERRMC=SCHEME_TYPE, DRIVER=3.63.123
回答by Stephen C
According to this page, DB2 SQL error code -407
means:
根据此页面,DB2 SQL 错误代码-407
表示:
-407 - AN UPDATE, INSERT, OR SET VALUE IS NULL, BUT THE OBJECT COLUMN column-name CANNOT CONTAIN NULL VALUES
-407 - 更新、插入或设置值为 NULL,但对象列列名不能包含 NULL 值
The State Code is saying the same thing:
州法典也说了同样的话:
23502 - An insert or update value is null, but the column cannot contain null values.
23502 - 插入或更新值为空,但该列不能包含空值。
But you are apparently getting this error for this ALTER statement:
但是您显然在此 ALTER 语句中收到此错误:
alter table BLP.COUNTER_EXTRACTION_REQUEST alter column SCHEME_ID set not null
So I suspect that in this context the error code means that the column currently contains null values, and you can't add a "not null" constraint to the column until you have eliminated them.
因此,我怀疑在这种情况下,错误代码意味着该列当前包含空值,并且在消除它们之前,您无法向该列添加“非空”约束。
回答by aravinda Challa
two ways:
两种方式:
First one: Drop the column from the table. Re-create with not null.
第一个:从表中删除列。用非空重新创建。
second one: update the column=' default value' where column date = null and change to null.
第二个:更新 column=' default value' 其中 column date = null 并更改为 null。