How to use nested CASE conditional expression in function using PostgreSQL?
For example the following function is created to calculate two numbers:
create or replace function fun(n integer) returns void as
$body$
declare
a int :=10;
b int :=5;
addition int :=0;
subs int :=0;
begin
select n,
case when n=1 then
addition:=a+b;
raise info '%',addition;
case when n=2 then
subs:=a-b;
raise info '%',subs;
end
end;
$body$
language plpgsql;
--Calling function
select fun(1);