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??
5201
December 11, 2005 08:50AM
2124
December 12, 2005 04:35AM
1981
December 12, 2005 07:23AM
1985
December 12, 2005 07:28AM
1849
December 12, 2005 05:06PM
1793
December 12, 2005 07:50PM
1707
December 13, 2005 04:42AM
3205
December 13, 2005 06:29AM
2463
December 13, 2005 07:39AM
1800
December 13, 2005 08:08AM
1677
December 13, 2005 03:18PM
1740
December 13, 2005 07:54PM
1776
December 15, 2005 06:04AM
1632
December 15, 2005 10:07AM
2050
January 15, 2006 11:50AM