0

I have a function that works inside my script but when I try to run it on my Sequel Pro MariaDB to add it to the function list, I get a bunch of errors.

drop function if exists related_count;
create function related_count(parent int(11)) returns int(11)
begin
 declare count int(11) default 0;
 while parent!=0 and count<10 do
  set count=count+1;
  set parent=(select related from category where id=parent);
 end while
 return count
end

enter image description here

Maciek Semik
  • 1,872
  • 23
  • 43

1 Answers1

1
  • You need a pair of DELIMITER statements.

  • More statements need a terminating ;.

Look in the docs and this forum for examples of CREATE FUNCTION.

Rick James
  • 135,179
  • 13
  • 127
  • 222