Stored Procedure problem

Stored Procedure problem

am 31.01.2007 07:42:51 von peterloh

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

am 01.02.2007 23:44:20 von peterloh

On Jan 31, 4:42 pm, "Peter" 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.