Why the heck is (expr <> '') allowed?
575531May 2 2007 — edited May 6 2007Peace be with you all!
Ok, after years of dealing with SQL Server, I'm learning a real db - Oracle 9i. I didn't
know that a stored procedure lang could be a real programming language. PL/SQL is
so very nice, but there is what appears to me to be a huge problem.
I now know that the empty string, '', is treated as null when used in an assignment
statement. What I can't understand is why these expressions are allowed by the
compiler as they will always evaluate to false:
expr = ''
expr <> ''
expr != ''
Am I missing something, or is there no possible semantic purpose for any of these
comparisons? Why does this not generate a compilation error?
And one last thing: I'm always (for now) dealing with these in the context of the
varchar2 type, not the fixed-width char types, although it doesn't seem to me
that the result would be any different, though it seems possible that the '' could
be interpreted differently if the LHS of the comparison evals to a fixed-width
char type.
Thanks in advance,
Robert McCall
Lasting peace & happiness for ALL non-violent human beings.