Home » SQL & PL/SQL » SQL & PL/SQL » How to detect if a field is empty?
How to detect if a field is empty? [message #190048] Tue, 29 August 2006 02:31 Go to next message
Messages: 21
Registered: August 2006
Junior Member
I am writing an PL/SQL program but how do you detect if a particular field is null or having an empty value.

test VARCHAR(9) := '';
select ID from mytable into test where A = B;

IF ((test = null) OR (test = '')) THEN

... can't get it to work... =(
Re: How to detect if a field is empty? [message #190057 is a reply to message #190048] Tue, 29 August 2006 03:00 Go to previous message
Messages: 7062
Registered: December 2001
Senior Member
NULL, as it is the absence of a value, cannot be compared with an equal sign. You check for NULLs with the 'IS (NOT) NULL' comparison:
If my_field IS NULL 
  -- do something here --
End If;

Previous Topic: Sequence
Next Topic: Max(count(xxx))
Goto Forum:

Current Time: Thu Aug 17 18:27:37 CDT 2017

Total time taken to generate the page: 0.18743 seconds