Discussion:
Stored Procedure problem
(too old to reply)
Peter
2007-01-31 06:42:51 UTC
Permalink
Hi,

I'm trying to create a stored procedure using the following syntax,
but I'm getting an error.

CREATE PROCEDURE `site`.`sp_ValidateInvite_SEL` (invitecode
varchar(10))
BEGIN

-- Check that the code exists (deleted/blocked users' invites will be
deleted)
IF NOT EXISTS (SELECT * FROM `invitations` WHERE `InvitationCode` =
invitecode) THEN
SELECT 'Error' As `Status`, 'Invitation Code is invalid.'
As `Details`;
ELSE
SELECT 'Invited' As `Status`, 'blahblah' As `Details`;
END IF

END


Could someone tell me what the problem could be? Can you use the EXIST
function as a condition (or a parameter within a EXIST function/
subquery)?

I'm using MySQL Administrator which automatically add the delimiter
statement.

Regards,

Peter
Peter
2007-02-01 22:44:20 UTC
Permalink
Post by Peter
Hi,
I'm trying to create a stored procedure using the following syntax,
but I'm getting an error.
CREATE PROCEDURE `site`.`sp_ValidateInvite_SEL` (invitecode
varchar(10))
BEGIN
-- Check that the code exists (deleted/blocked users' invites will be
deleted)
IF NOT EXISTS (SELECT * FROM `invitations` WHERE `InvitationCode` =
invitecode) THEN
SELECT 'Error' As `Status`, 'Invitation Code is invalid.'
As `Details`;
ELSE
SELECT 'Invited' As `Status`, 'blahblah' As `Details`;
END IF
END
Could someone tell me what the problem could be? Can you use the EXIST
function as a condition (or a parameter within a EXIST function/
subquery)?
I'm using MySQL Administrator which automatically add the delimiter
statement.
Regards,
Peter
Nevermind... needed to add ';' to the end of END IF.

Loading...