MySQL Forums
Forum List  »  Microsoft SQL Server

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:

SELECT FirstName, LastName, EMail FROM Users WHERE UserID = l_UserID;

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

Options: ReplyQuote

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.