Search

Showing posts with label Oracle. Show all posts
Showing posts with label Oracle. Show all posts

Monday, June 7, 2010

No empty strings in Oracle



This was pretty easy to find, but considering how unexpected it is, I feel it's worth a mention.

There are no empty strings in Oracle's SQL or PL/SQL.

Consider -
myVar VARCHAR2(10) := '';

The following will never execute.
IF myVar = '' THEN
-- do something
END IF;

myVar must be compared to NULL for the block to work.
IF myVar IS NULL
-- do something
END IF;

Likewise
SELECT someField
FROM   someTable
WHERE  someField = '';
Will always return 0 rows.