Boa tarde!
Preciso criar uma função no Mysql 5 mas não consigo acertar a sintaxe, alguém pode ajudar por favor
Segue o script abaixo que dá vários erros
identar texto pre-formatado em 4 espaços
CREATE FUNCTION getFluxoSite (idSiteLocal int) RETURNS VARCHAR(60)
BEGIN
DECLARE v_s_retorno, v_s_retorno_aux VARCHAR(60);
ret: LOOP
begin
declare continue handler
for not found set v_s_retorno_aux = null;
select tf.acronym
from eim.tipo_fluxo tf
WHERE exists (select 1
from eim.site_rf sr,
eim.project_site ps,
eim.step_status ss,
eim.fase f,
eim.step s
where s.tipo_fluxo_id = tf.id
and ss.step_id = s.id
and ss.fase_id = f.id
and ps.site_rf_id = sr.id
and sr.site_local_id = id_site_local
and concat(s.description,' ',f.description) = ps.status);
end;
if v_s_retorno is null then
set v_s_retorno = v_s_retorno_aux;
else
set v_s_retorno = concat(v_s_retorno,' - ',v_s_retorno_aux);
end if;
if (v_s_retorno_aux is null) then
leave ret;
end if;
end loop ret;
return v_s_retorno;
end;