Skip navigation links

MySQL Forums :: Microsoft SQL Server :: In Stored Procedure, how to check if variable is NULL?


Advanced Search

Re: In Stored Procedure, how to check if variable is NULL?
Posted by: Roland Bouman ()
Date: August 22, 2005 06:02AM

BTW, what is

UserID <> NULL

supposed to do anyway? As far as i can see, this *never* evaluates to TRUE, even if UserID would be NULL. In fact, anything compared to NULL using a relational operator always evaluates to UNKNOWN. Now, UNKNOWN is not exactly FALSE, but is definitely is not TRUE, so, the IF branch never executes.
This behaviour has nothing to do with the platform, NULLs behave similar in MSSQL and MySQL in this respect.

...

There's something else: IF statements in MySQL are blocks. You should end an IF using an END IF:

IF l_UserID IS NULL
SELECT FirstName, LastName, EMail FROM Users WHERE UserID = l_UserID;
END IF;

This is just illustration, for a solutions, stick to what I posted earlier.

Options: ReplyQuote


Subject Written By Posted
In Stored Procedure, how to check if variable is NULL? neilc 08/18/2005 05:53PM
Re: In Stored Procedure, how to check if variable is NULL? Roland Bouman 08/22/2005 03:06AM
Re: In Stored Procedure, how to check if variable is NULL? Roland Bouman 08/22/2005 06:02AM
Re: In Stored Procedure, how to check if variable is NULL? neilc 08/22/2005 03:18PM
Re: In Stored Procedure, how to check if variable is NULL? Roland Bouman 08/22/2005 04:02PM
Re: In Stored Procedure, how to check if variable is NULL? neilc 08/22/2005 04:34PM
Re: In Stored Procedure, how to check if variable is NULL? Roland Bouman 08/22/2005 05:03PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.