Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Why it is not a compilation error?

Re: Why it is not a compilation error?

From: Andreas Sheriff <spamcontrol_at_iion.com>
Date: Wed, 13 Jul 2005 08:03:54 -0700
Message-ID: <t3aBe.30585$8o.24979@fed1read03>


<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 newsgroup 
Received on Wed Jul 13 2005 - 10:03:54 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US