I need to write a very simple Firebird function
create or alter function some_function (A NUMERIC, B NUMERIC)
returns double precision
as
begin
return
case
when (B <= 2.5) then A - 2
when (B <= 5.0) then A - 1
else A
end;
end;
However, if flags the first end; as an "Unexpected end of command error". My first thought was that maybe Firebird does not allow to return a searched case in a function, so I rewrote it as:
create or alter function some_function (A NUMERIC, B NUMERIC)
returns double precision
as
declare result double precision;
begin
result = case
when (B <= 2.5) then A - 2
when (B <= 5.0) then A - 1
else A
end;
return result;
end;
But again, it flags the same error, now at the first end;. Firebird documentation about searched case (https://firebirdsql.org/refdocs/langrefupd15-case.html) even shows almost the same scenario. What is wrong? Of course, I solved it using traditional if then/else
but I want to know if I misspelled something or maybe Firebird (WI-V3.0.7.33374 Firebird 3.0/64/W2012) has some bug.