I have created a function that does not give any errors itself but when calling it I get an error. I know I technically don’t need a function but for my scenario I need to be using one.
The error:
QUERY "SELECT (show_date) FROM show" returned more than one row.
CONTEXT: PL/PGSql function change_data_type() line 3 at RETURN
CREATE OR REPLACE FUNCTION change_data_type()
RETURNS date as $$
BEGIN
RETURN DATE(show_date) FROM show;
END;
$$ LANGUAGE PLPGSQL;
SELECT change_data_type();
2
Answers
with one record:
will not return an error
but with more than 1 record:
it will, see: DBFIDDLE
See:
https://www.postgresql.org/docs/current/plpgsql-control-structures.html