In Stored Procedure, how to check if variable is NULL?
Posted by:
neilc
Date: August 18, 2005 05:53PM
I am assigned to convert a bunch of MSSQL stored procedure to MySQL stored procedures in version 5.0. There are syntax differences and I am stuck in many of these and the usual "syntax error" messages are not very helpful.
So I have in MSSQL:
/*GetUser*/
CREATE PROCEDURE GetUser
(
Username VARCHAR(50)
)
BEGIN
DECLARE UserID int;
SELECT UserID = UserID FROM Memberships WHERE Username = Username;
IF UserID <> NULL
SELECT FirstName, LastName, EMail FROM Users WHERE UserID = UserID;
END
In MYSQL I have so far:
/*GetUser*/
CREATE PROCEDURE `eiffelsupport`.`GetUser`
(
a_Username VARCHAR(50)
)
BEGIN
DECLARE l_UserID INT;
SELECT l_UserID = UserID FROM Memberships WHERE Username = a_Username;
IF l_UserID IS NULL
SELECT FirstName, LastName, EMail FROM Users WHERE UserID = l_UserID;
END
The problem is in how to acheive the same as IF UserID <> NULL in MYSQL?
Thanks in advance?
---
NC
Subject
Written By
Posted
In Stored Procedure, how to check if variable is NULL?
August 18, 2005 05:53PM
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.