Seaquel
PostgreSQL error code

PostgreSQL error 2F005

2F005 is the SQLSTATE PostgreSQL reports for function executed no return statement, in class 2F, SQL Routine Exception.

SQLSTATE2F005
Condition namefunction_executed_no_return_statement
Class2F — SQL Routine Exception

Reproduce it, then fix it

For x of 0 or less, the function reaches its end without hitting a RETURN. Every path through a PL/pgSQL function that returns a value needs one. Run the broken query to see the error, then switch to the fixed one. Edit either freely; every run is rolled back.

CREATE FUNCTION sign_label(x int) RETURNS text AS $$
BEGIN
  IF x > 0 THEN
    RETURN 'positive';
  END IF;
END $$ LANGUAGE plpgsql;

SELECT sign_label(-1);
CREATE FUNCTION sign_label(x int) RETURNS text AS $$
BEGIN
  IF x > 0 THEN
    RETURN 'positive';
  END IF;
  RETURN 'not positive';
END $$ LANGUAGE plpgsql;

SELECT sign_label(-1);

Source: PostgreSQL documentation, Appendix A