Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to test if a column has the value NULL?

user639304Jul 19 2011 — edited Jul 19 2011
Hi,

I have a table T with 3 columns ID number and name varchar2(500) and address Varchar2(500). I wrote a PL/SQL procedure which uses a cursor based on table T and makes some processing if the actual row in the cursor has an address which has a value which is not NULL, and another processing if address has the value NULL.
Here's my procedure:
create or replace procedure proc_T is
cursor cur is select id, name, address
from T
order by id;

BEGIN

FOR c in curs
   LOOP
     If c.address is null then
        --processing1
     else
        -- processing2
    end if;
  END LOOP;
END;
My table contains 20 rows.
The problem is that for the first iteration in the for loop, I'm sure c.address has the value NULLl, but processing1 is not done, and instead, it's processing2 which is done. How should I do to ensure that if c.address has the value NULL, then the procedure enters in the if branch( i.e. executes processing1) and not in the else branch (where processing2 is executed)?
Thanks.
This post has been answered by 21205 on Jul 19 2011
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 16 2011
Added on Jul 19 2011
5 comments
747 views