Unanswered: Leaving a Stored Procedure
Is there any way to exit out of a stored procedure? Checked out EXIT and LEAVE but doesn't seem to be doing the trick:
Here's the proc:
DECLARE dateExpiretime TIMESTAMP;
DECLARE dateStartTime TIMESTAMP;
DECLARE ERROR_CURSOR1 CURSOR WITH RETURN FOR SELECT 'NOT A VALID CONNECTION' FROM SYSIBM.SYSDUMMY1;
DECLARE ERROR_CURSOR2 CURSOR WITH RETURN FOR SELECT 'CONNECTION NO LONGER VALID. CONNECTION CLOSED' FROM SYSIBM.SYSDUMMY1;
DECLARE CURSOR1 CURSOR WITH RETURN FOR SELECT 'VALID CONNECTION' FROM SYSIBM.SYSDUMMY1;
IF decAIMConnectionID NOT IN (SELECT AIMConnectionID FROM AIM.AIMCONNECTION) THEN
SET dateStartTime = (SELECT StartDateTime FROM AIM.AIMCONNECTION WHERE AIMCONNECTIONID = decAIMConnectionID);
SET dateExpireTime = dateStartTime + 8 HOURS;
IF CURRENT TIMESTAMP > dateExpireTime THEN
UPDATE AIM.AIMCONNECTION SET ENDDATETIME = CURRENT TIMESTAMP,
TerminationReason = 'Expired' WHERE AIMConnectionID = decAIMConnectionID;
After the proc opens CURSOR1 (if it has to), I want to jump to the end of the procedure and cease processing.
"If I'm curt with you, it's because time is a factor here. I think fast, I talk fast, and I need you guys to act fast if you want to get out of this. So, pretty please - with sugar on top..."