Home:ALL Converter>PostgreSQL Function Return Type Error

PostgreSQL Function Return Type Error

Ask Time:2017-07-19T21:04:20         Author:WhaleShark

Json Formatter

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?

Author:WhaleShark,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/45191502/postgresql-function-return-type-error
yy