I am new to POSTGRES and currently exploring how to create and execute stored procedures. I was trying a simple example with conditional constructs and got stuck with an error :(
create procedure learnpostgre(x integer, y integer)
language plpgsql
as $$
if x > y
then
raise 'X is greater'
end if
$$;
The error I am getting is 'syntax error at or near if'. I saw similar issues on SO and tried wrapping my code block under do block but faced the same error message for 'Do'. I am running my code in pgadmin4 and postgres version is 14.X
begin ... endblock in PL/pgSQL