Select to view content in your preferred language

Definition query behavior with null records

552
4
Jump to solution
12-30-2024 01:51 PM
Labels (1)
LyonMNGIS
Frequent Contributor

Hello,

I am using ArcGIS Pro 3.4 and have a definition query on a layer set to display a records as long as the value is not "hidden".  However, if a record is <null> then the record does not display at all.

I would expect any null records to show up on the map because they are not equal to hidden.  Am I missing something?

SQL

Check <> 'Hidden'

Thanks!

 

1 Solution

Accepted Solutions
JoshuaBixby
MVP Esteemed Contributor

Regarding


@LyonMNGIS wrote:
...

I would expect any null records to show up on the map because they are not equal to hidden.  Am I missing something?

...


The existence or possibility of NULL means SQL operators implement three-valued or ternary logic.   Instead of the true/false outcomes of boolean logic, there are true/false/unknown outcomes.  If you write:

check <> 'Hidden'

The records that are NULL return unknown, not true or false.  Since the result is unknown, the database will not return them because it is possible they could be 'Hidden', and it only returns records that are guaranteed not to be 'Hidden'.

There are people who strongly oppose allowing or using NULL in any data model, including CJ Date who is credited with creating the relational model that SQL databases partially implement.

I will note that prior to ArcGIS Pro 3.3, Esri's implementation of three-valued logic with certain operators in the file geodatabase was inconsistent with SQL standards and the rest of the industry.  Esri fixed the issue to be consistent with everyone else at Pro 3.3, but it also means certain queries can produce different results between Pro 3.2 and earlier and Pro 3.3 and later.

View solution in original post

4 Replies
Robert_LeClair
Esri Esteemed Contributor

You're almost there!  You need to add one more SQL statement to get the features that don't have hidden in them or there is a NULL value in the field.  Here's the SQL statement that worked for me:

Check <> 'Hidden' Or Hidden IS NULL

This will show all values NULL or other attribute values but NOT show Hidden.

LyonMNGIS
Frequent Contributor

Robert,

Thank you I did add or hidden is null and everything works as expected.

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

Regarding


@LyonMNGIS wrote:
...

I would expect any null records to show up on the map because they are not equal to hidden.  Am I missing something?

...


The existence or possibility of NULL means SQL operators implement three-valued or ternary logic.   Instead of the true/false outcomes of boolean logic, there are true/false/unknown outcomes.  If you write:

check <> 'Hidden'

The records that are NULL return unknown, not true or false.  Since the result is unknown, the database will not return them because it is possible they could be 'Hidden', and it only returns records that are guaranteed not to be 'Hidden'.

There are people who strongly oppose allowing or using NULL in any data model, including CJ Date who is credited with creating the relational model that SQL databases partially implement.

I will note that prior to ArcGIS Pro 3.3, Esri's implementation of three-valued logic with certain operators in the file geodatabase was inconsistent with SQL standards and the rest of the industry.  Esri fixed the issue to be consistent with everyone else at Pro 3.3, but it also means certain queries can produce different results between Pro 3.2 and earlier and Pro 3.3 and later.

LyonMNGIS
Frequent Contributor

Joshua,

Thank you for your help.  That would explain why the behavior seemed to have changed.

0 Kudos