MySQL - como crear funciones

 
Vista:

como crear funciones

Publicado por felipe (7 intervenciones) el 31/05/2007 22:43:11
hola,
soy novato en mysql y estoy tratando de crear la siguiente funcion

delimiter$
CREATE FUNCTION hello(s VARCHAR(20)) RETURNS VARCHAR(50)
BEGIN
IF s = 'test' THEN RETURN 'haha';
END IF;
RETURN'hoho'
end$
delimiter;

resulta que cuando escribo el ";" (punto y coma) me sale el siguiente error
error 1064 (42000): you have an error in your sql sintax; check the manual that corresponds to your mysql server version for the right sintax to use near RETURN 'haha'' at line 3

LA VERSION CON QUE TRABAJO ES mysql-essential-5.2.3-falcon-alpha-win32
ojala puedan ayudarme gracias.
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

RE:como crear funciones

Publicado por kain (124 intervenciones) el 04/06/2007 22:42:59
esta te va a funionar.

CREATE FUNCTION hello(s VARCHAR(20))
RETURNS VARCHAR(50)
BEGIN
IF s = 'test' THEN RETURN 'haha';
END IF;
RETURN 'hoho';
end;
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

RE:como crear funciones

Publicado por JC (3 intervenciones) el 06/06/2007 23:34:09
delimiter $
CREATE FUNCTION hello(s VARCHAR(20)) RETURNS VARCHAR(50)
BEGIN
IF s = 'test' THEN RETURN 'haha';
END IF;
RETURN 'hoho' ;
end$
delimiter ;
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