You can't have a command inside the case
. Use the case as a parameter to raise
.
create or replace function fun(n integer) returns void as
$body$
declare
a int := 10;
b int := 5;
begin
raise info '%', case n
when 1 then a + b
else a - b
end
;
end;
$body$
language plpgsql;
select fun(1);
INFO: 15
fun
-----
(1 row)
select fun(2);
INFO: 5
fun
-----