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
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


0