空值约束问题 [英] null value constraints issue
问题描述
update sc_bill_details set dt_open_date =(select dt_bill_date from sc_bill where dt_bill_date>'2015-7-1' and sc_bill.st_bill_no=sc_bill_details.st_bill_no )
当写上面的查询时,即使两个表中都没有空值,也会出现跟随错误。
when m writing above query getting following error even after there is no null values in both the tables.
ERROR: null value in column "dt_open_date" violates not-null constraint
DETAIL: Failing row contains (VC2009030000242, VC20090300189, null, -1, -1, ECG, 1, 100, 100, 0, 9, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0).
推荐答案
显然
Obviously the
select dt_bill_date from sc_bill where dt_bill_date>'2015-7-1' and sc_bill.st_bill_no=sc_bill_details.st_bill_no
查询不返回任何值。
我搜索了PostGRE日期时间规范格式;你试过把两位数写入月份和日期数字吗?我没有看到任何相关内容,但我发现的所有示例都使用'2015-07-01'作为日期规范格式而不是'2015-7-1'。我不知道PostGRE的内部结构,也没有根据这个RDBMS开发任何内容,但是值得尝试。
您也可以更改比较运营商到> =
,看看是否会返回一些记录。
您也可以尝试使用
query does not return any value.
I have searched for PostGRE datetime specification formats; have you tried to put two digits to the month and day numbers? I did not see anything about that, but all examples I can find use '2015-07-01' as date specification format rather than '2015-7-1'. I don't know the internals of PostGRE, nor did I ever develop anyhting based on this RDBMS, but it could be worth trying.
You could also change the comparison operator to >=
and see if that returns some records.
You could also try with
select dt_bill_date
from sc_bill
inner join sc_bill_details on sc_bill.st_bill_no=sc_bill_details.st_bill_no
where dt_bill_date>'2015-07-01'
希望这会有所帮助。祝你好运。
Hope this helps. Good luck.
这篇关于空值约束问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!