I am very new and trying to teach my self PostgreSQL. At the moment I am trying to create a function which updates a column based on the values of two other columns in the same table. I am creating the function as I want to call it as a trigger to execute when the column values are edited. All colomns are holding text.
My code is:
CREATE FUNCTION rev_1.update_proceed_column() RETURNS character varying AS
$BODY$
UPDATE rev_1.catchment_e_gravity_lines SET proceed = 'N/A'
WHERE installed = 'YES' AND dependent = 'YES';
UPDATE rev_1.catchment_e_gravity_lines SET proceed = 'N/A'
where installed = 'YES' AND dependent ='NO';
UPDATE rev_1.catchment_e_gravity_lines SET proceed = 'YES'
WHERE installed = 'NO' AND dependent = 'NO';
UPDATE rev_1.catchment_e_gravity_lines SET proceed = 'NO'
WHERE installed = 'NO' AND dependent = 'YES';$BODY$
LANGUAGE sql VOLATILE NOT LEAKPROOF;
ALTER FUNCTION rev_1.update_proceed_column()
OWNER TO postgres;
I am however getting an error of 'return type mismatch' and cant seem to get a function working. Am I missing something?