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
cacheboy
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
...
END IF;

... 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
Maaher
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 
Then
  -- do something here --
End If;


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


Current Time: Tue Dec 06 04:39:08 CST 2016

Total time taken to generate the page: 0.11741 seconds