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
peterloh [ Mi, 31 Januar 2007 07:42 ] [ ID #1614007 ]

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.
peterloh [ Do, 01 Februar 2007 23:44 ] [ ID #1615253 ]
Datenbanken » mailing.database.mysql » Stored Procedure problem

Vorheriges Thema: Warning 1292 "Incorrect date value:"
Nächstes Thema: COMMENTS in INFORMATION_SCHEMA