RE: Useful Oracle books - C.J. Date theory vs. practicality

  • From: "Lex de Haan" <lex.de.haan@xxxxxxxxxxxxxx>
  • To: <oracle-l@xxxxxxxxxxxxx>
  • Date: Fri, 28 May 2004 21:56:08 +0200

Jared, I stored your example in a script, making it prompt for a condition:

SQL*Plus: Release 10.1.0.2.0 - Production on Fri May 28 21:51:24 2004
Copyright (c) 1982, 2004, Oracle.  All rights reserved.

SQL> @jared
Enter value for condition: 'Mort subite' = NULL
ELSE branch
ELSE branch

PL/SQL procedure successfully completed.

SQL> @jared
Enter value for condition: 1=1
THEN branch
ELSE branch

PL/SQL procedure successfully completed.

SQL> list
  1  begin
  2    if     (&&condition) then
  3           dbms_output.put_line('THEN branch');
  4    else
  5           dbms_output.put_line('ELSE branch');
  6    end    if;
  7    if not (&condition) then
  8           dbms_output.put_line('THEN branch');
  9    else
 10           dbms_output.put_line('ELSE branch');
 11    end if;
 12* end;
SQL>

Kind regards,
Lex.

---------------------------------------------
visit my website at http://www.naturaljoin.nl
---------------------------------------------

-----Original Message-----
From: oracle-l-bounce@xxxxxxxxxxxxx [mailto:oracle-l-bounce@xxxxxxxxxxxxx]On
Behalf Of Powell, Mark D
Sent: Friday, May 28, 2004 20:48
To: 'oracle-l@xxxxxxxxxxxxx'
Subject: RE: Useful Oracle books - C.J. Date theory vs. practicality


I think the point was if part of some condition was Null then the statement
is not true, but is not false either as technically the result is unknown so
in pl/sql you potentially should have a construct that looks like

If true
   ...
Else if false
  ...
Else [it is null so]

I have seen more than one bug traced to the failure of a developer to
remember that in pl/sql just because something is not true that does not
mean it is false.  Failure to remember this results in attempts to find rows
for the FALSE condition when there is no value to be used to query for those
rows.

In native COBOL there is only True and False.  However if you use COBOL with
an RDBMS both Oracle and DB2 provide a null value indicator feature that can
be used to allow program logic to properly handle the data.  No matter what
language is used when the data comes from an RDBMS that supports NULLs this
issue of TRUE/ FALSE/ NULL probably exists.

Just adding to the noise level.
-- Mark D Powell --
BEGIN:VCARD
VERSION:2.1
N:de Haan;Lex
FN:Lex de Haan
ORG:Natural Join B.V.
TEL;WORK;VOICE:+31.30.2515022
TEL;HOME;VOICE:+31.30.2518795
TEL;CELL;VOICE:+31.62.2955714
TEL;WORK;FAX:+31.30.2523366
ADR;WORK:;;Pieter Breughelstraat 10;Utrecht;;3583 SK;Netherlands
LABEL;WORK;ENCODING=QUOTED-PRINTABLE:Pieter Breughelstraat 10=0D=0AUtrecht 3583 
SK=0D=0ANetherlands
URL;WORK:http://www.naturaljoin.nl
EMAIL;PREF;INTERNET:lex.de.haan@xxxxxxxxxxxxxx
REV:20040224T160439Z
END:VCARD

Other related posts: