我有一个带有非空限制的日期字段(数据类型 ingresdate)的 Ingres 表。但是允许空白,即空值。如何检查空白值?
当然,使用 ifnull() 测试空值是行不通的——如下例所示。
INGRES TERMINAL MONITOR Copyright 2008 Ingres Corporation
Ingres SPARC SOLARIS Version II 9.2.3 login
continue
create table test ( id integer not null, date_field ingresdate not null with default )\g
insert into test (id, date_field) values ( 1, '' )\g
insert into test (id, date_field) values ( 2, '31/12/2014' )\g
continue
(1 row)
continue
select id, date_field, ifnull( date_field, '01/01/2014' ) as test_field from test\g
(1 row)
continue
+-----------------------------------------------------------------+
¦id ¦date_field ¦test_field ¦
+-------------+-------------------------+-------------------------¦
¦ 1¦ ¦ ¦
¦ 2¦31/12/14 ¦31/12/14 ¦
+-----------------------------------------------------------------+
(2 rows)
continue
\q
Your SQL statement(s) have been committed.
Ingres Version II 9.2.3 logout