Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8541827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:55:09+00:00 2026-06-11T11:55:09+00:00

I was debugging a procedure in an oracle database when I came across something

  • 0

I was debugging a procedure in an oracle database when I came across something that surprised me regarding NULL values. Can anybody explain why the following query returns false for the non equality check here?

DECLARE
    vNullVariable VARCHAR2(2) := NULL;
    vVariable VARCHAR2(2) := 'Hi';
BEGIN
    IF vNullVariable <> vVariable THEN
        dbms_output.put_line( 'The variables are not equal' );
    ELSE
        dbms_output.put_line( 'The variables are equal' );
    END IF;
END;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T11:55:10+00:00Added an answer on June 11, 2026 at 11:55 am

    This is because SQL uses three-valued logic (3VL): there is TRUE, there is FALSE and there is NULL (unknown, neither TRUE nor FALSE).

    The result of the expression vNullVariable <> vVariable is NULL, not TRUE, in 3VL because it considers the value of vNullVariable to be unknown: if at a later time it becomes a known value, it might be ‘Hi’ or it might not, but right now SQL doesn’t know so it returns NULL (unknown).

    So the IF expression evaluates to NULL, not TRUE, and so the default ELSE path is taken instead – because the logic if IF is:

    IF <expression is true> THEN
       ...
    ELSE -- ie. if expression is FALSE or NULL
       ...
    END IF;
    

    This means that you would get the behaviour you were expecting if you wrote the check the other way around:

    IF vNullVariable = vVariable THEN
        dbms_output.put_line( 'The variables are equal' );
    ELSE
        dbms_output.put_line( 'The variables are not equal' );
    END IF;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was debugging a stored procedure the other day and found some logic something
I have following procedure which is filling up null values in a column. The
So i have a procedure that i'm currently in the process of debugging and
I'm looking to create a procedure that helps with debugging specific variables, and for
I came to know of the remote debugging procedure under Idea recently. What I
Hi I have problem that I can't solve alone since damn debugging doesn't work
I have a problem when debugging stored procedure using SQL server Management Studio 2008.
When debugging in Visual Studio and you want to step into a procedure for
Debugging a PHP program, is there any add-on/plug-in for browser which I can view
I have a .net web application that makes heavy use of oracle stored procedures.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.