How to return null/empty resultset from SP??
Posted by:
Ming Yeung
Date: December 11, 2005 08:50AM
Hi guys,
I tried to search for my problem, but with no luck.
Below is my SP, it is a very simple one.
CREATE PROCEDURE `adminCheckLogin`(IN inUsername varchar(20), IN inPassword char(32))
BEGIN
DECLARE ret_id INT;
SELECT id INTO ret_id FROM admin WHERE username = inUsername AND password = inPassword;
IF ret_id IS NOT NULL THEN
UPDATE admin SET date_lastlogin = NOW() WHERE id = ret_id;
END IF;
SELECT ret_id;
END
What It does is to check the user's login and if the user is there, then update the login time, and return the user id.
If the user is found, of course, it returns the user id. But the problem I have is that the SP returns(always) 0 if user is not found, which it shouldn't.
Therefore, the first statement from the java code will always pass:
if(rs.next())
// Found...
else
// Not found ...
...
So how do I return a null resultset ?? e.g. SELECT NULL, etc..;
Thanks a lot.
Subject
Views
Written By
Posted
How to return null/empty resultset from SP??
5188
December 11, 2005 08:50AM
2118
December 12, 2005 04:35AM
1973
December 12, 2005 07:23AM
1975
December 12, 2005 07:28AM
1843
December 12, 2005 05:06PM
1788
December 12, 2005 07:50PM
1701
December 13, 2005 04:42AM
3190
December 13, 2005 06:29AM
2445
December 13, 2005 07:39AM
1790
December 13, 2005 08:08AM
1667
December 13, 2005 03:18PM
1733
December 13, 2005 07:54PM
1769
December 15, 2005 06:04AM
1622
December 15, 2005 10:07AM
2040
January 15, 2006 11:50AM