MySQL - crear funciones

 
Vista:

crear funciones

Publicado por carlos (1 intervención) el 30/04/2009 08:57:45
alguien podria decirme por que la siguiente definicion de una funcion me da un error de sintaxis en SQL???

DELIMITER //
CREATE FUNCTION existe_priv(
xproyecto integer,
xusuario integer
) RETURNS integer
BEGIN
IF EXISTS (
SELECT 1
FROM privilegios_proyecto
WHERE usuario = xusuario
AND proyecto = xproyecto
AND tipo_usuario = "Administrador"
)
then RETURN (1);
ELSE RETURN (0);
END
//
DELIMITER ;

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 15

la linea 15 es la anterior al "END".. me parece q es el "if exists" el q ocasiona el problema pero tengo entendido q asi es la sintaxis del mismo.. gracias de antemano
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
sin imagen de perfil

RE:crear funciones

Publicado por DALSOM (23 intervenciones) el 20/06/2010 01:43:02
PUES VEO QUE LE FALTAN LOS PARENTESIS AL IF().

PRUEBA NO SEA OTRA COSA.

SALUDOS,
DALSOM.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar