Article
· Sep 5 1m read

Handling NULL in SQL

InterSystems FAQ rubric

In SQL, NULL data and the empty string ('') are different data. The method for setting and checking each is as follows.

(1) NULL data

[SQL] 

insert into test(a) values(NULL)
select * from test where a IS NULL

[InterSystems ObjectScript]

set x=##class(User.test).%New()
set x.a=""

(2) Empty string ('')

[SQL]

insert into test(a) values('')
select * from test where a = ''

[InterSystems ObjectScript]

set x=##class(User.test).%New()
set x.a=$C(0)

For more information, please refer to the following documents:

NULL and empty strings [IRIS]
NULL and empty strings

Discussion (0)1
Log in or sign up to continue