Stored Procedure problem
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
Re: Stored Procedure problem
On Jan 31, 4:42 pm, "Peter" <peter... [at] gmail.com> wrote:
> 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.