[英]DB2 SQLCODE = -420, ERROR when comparing smallint fields with nulls
I am trying to compare two smallint fields to look for differences. 我正在尝试比较两个smallint字段以寻找差异。 One table is a pending change table that is read by a batch job at night that then updates the other table along with doing other activities.
一个表是一个挂起的更改表,批处理作业在晚上读取该表,然后更新另一个表并执行其他活动。 The batch job has some issues and I'm researching the problems.
批处理作业有一些问题,我正在研究这些问题。 I want to find those values that are different and show what the pending table's value is when that occurs.
我想找到那些不同的值,并在发生时显示待处理表的值。
The specific column(s) (CO_FT_FREQ_DAY) that are giving me trouble have nulls in the smallint field and I think that is the cause of my issues. 给我带来麻烦的特定列(CO_FT_FREQ_DAY)在smallint字段中为空,我认为这是导致我出现问题的原因。 (or it could be a pending add so there is no matching value to compare to...) As you can see I've tried to address the issue but it's still not working.
(或者它可能是一个待处理的添加,因此没有可比较的匹配值...)如您所见,我已尝试解决该问题,但仍无法正常工作。
I tried ifnull before this, but got the same error. 在此之前,我尝试过ifnull,但是遇到了同样的错误。 I was hoping that this would resolve the issue.
我希望这可以解决问题。
SELECT T342.clientID
,T342.TS_340
,case when (case when t342.CO_FT_FREQ_DAY is null then 0 else
t342.CO_FT_FREQ_DAY end) <>
(case when t340.CO_FT_FREQ_DAY is null then 0 else
t340.CO_FT_FREQ_DAY end)
then T342.CO_FT_FREQ_DAY
else 0
end as CO_FT_FREQ_DAY
FROM database.PendingChangeTable T342
left outer join database.CurrentTable T340
on T340.ClientID = T342.ClientID
and T340.TS_PK = T342.TS_340
WHERE t342.clientID in (clientID list);
DSNT408I SQLCODE = -420, ERROR: THE VALUE OF A STRING ARGUMENT WAS NOT DSNT408I SQLCODE = -420,错误:字符串参数的值不正确
ACCEPTABLE TO THE DECFLOAT FUNCTION 可接受的十进制功能
DSNT418I SQLSTATE = 22018 SQLSTATE RETURN CODE DSNT418I SQLSTATE = 22018 SQLSTATE返回码
UGH Found the problem. UGH发现了问题。 Whoever designed the table switched midstream and defined these new columns as char fields and I missed that.
设计表的人切换到中游并将这些新列定义为char字段,但我错过了。 So I needed to set the value to '0' instead of 0 in my case statement.
因此,我需要在case语句中将值设置为“ 0”而不是0。
,case when (case when t342.CO_FT_FREQ_DAY is null then '0' else
t342.CO_FT_FREQ_DAY end) <>
(case when t340.CO_FT_FREQ_DAY is null then '0' else
t340.CO_FT_FREQ_DAY end)
then T342.CO_FT_FREQ_DAY
else '0'
end as CO_FT_FREQ_DAY
,case when ifnull(t342.CO_HT_FREQ_DAY,'0') <>
ifnull(t342.CO_HT_FREQ_DAY,'0')
then ifnull(T340.CO_HT_FREQ_DAY,'0')
else '0'
end as CO_HT_FREQ_DAY
So the lesson for me today is ALWAYS check your datatypes when you get this error! 因此,今天给我的教训是,当您收到此错误时,请务必检查您的数据类型!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.