Oracle null value in quotes – yet another newbie question

nulloracle

I have a where clause like

"and uc.completion_status in ('[P....]') " 

here ('[P….]') is the user input from taken a dropdown list in the user interface. and dropdown list consists three options Y, N or NotStarted

not started is defined with nvl(uc.completion_status, 'NotStarted') therefore NotStarted is null actually. and null in quotes is not working. how can this problem can be handled?

thanks in advance.

Best Answer

Simple! Put NULL without quotes.

E.g.

INSERT INTO tableName (columnName1, columnName2) VALUES ('Value1', NULL)

We must always use NULL without quotes when we intend to use NULL values. Putting quotes around it, like 'NULL' makes it a string literal and it is treated as character data. Hence for using NULL values, we must always use NULL without quotes, be it a null string, a null number or a null BLOB. For every data type, we must use NULL without quotes.