I am starting to use plpgsql and postgresql and the truth is that I am a bit lost, I have an exercise in which I am asked to make a block that increases the salary of the employees by 10% of the average salary of the same, and I have done this:
CREATE OR REPLACE FUNCTION increment(salari INT) RETURNS int AS $$
DECLARE
increment int NOT NULL := salari + ((avg(salari) * 10)/100);
BEGIN
return salari + increment;
END;
$$ LANGUAGE plpgsql;
The case is that when applying the function does not return a correct result (I know that instead of the return
I have to do a update
and such, but I have put it like this to go testing) , I imagine that it will be because instead of an int, I have to work with some kind of data similar to double, but it does not recognize me.
Does anyone have any idea what I could do?