Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Why it is not a compilation error?
<Serguei.Goumeniouk_at_cibc.ca> wrote in message
news:1121266330.135919.205620_at_g43g2000cwa.googlegroups.com...
> Dear Experts,
> Could you please explain me the behavior of the following codes?
>
> .... Declaration section ...........
> volume number := NULL;
> .... Codes .........................
>
> IF (number = NULL) THEN
> .... do A actions .....
> END IF;
>
> IF (number IS NULL) THEN
> .... do B actions ......
> END IF;
>
> These if-blocks work in a different way (at least in my codes).
> 1) Why the first if-block is not a compilation error?
> 2) What the construction like "something = NULL" means?
>
> Regards,
> Serguei.
>
The first if statement is not an error. It'll just never evaluate to TRUE. Instead, it'll evaluate to NULL, which is neither TRUE nor FALSE. To compare against a null you have to use IS NULL and IS NOT NULL.
You see, in SQL, and PowerBuilder (coincidentally), there are three logic
states:
TRUE - A statement is true
FALSE - A statement is false
NULL - A statement is neither true nor false
Anyone have anything to add/dispute?
I can be almost positive someone will dispute this. :-D
-- Andreas Oracle 9i Certified Professional Oracle 10g Certified Professional Oracle 9i Certified PL/SQL Developer "If you don't eat your meat, you cannot have any pudding. "How can you have any pudding if you don't eat your meat?!?!" --- WARNING: DO NOT REPLY TO THIS EMAIL Reply to me only on this newsgroupReceived on Wed Jul 13 2005 - 10:03:54 CDT
![]() |
![]() |