Reputation: 15
I need to return a message (a different message according some evaluations inside de function), but when I call the function it returns this error message: "Returned type unknown does not match expected type character varying in column 2".
CREATE OR REPLACE FUNCTION myfunction()RETURNS TABLE(
cod INTEGER,
answ CHARACTER VARYING
) AS $BODY$
BEGIN
RETURN QUERY
select 0, 'here goes the message';
END;
$BODY$
LANGUAGE plpgsql;
Upvotes: 1
Views: 1979
Reputation: 51511
try:
CREATE OR REPLACE FUNCTION myfunction()RETURNS TABLE(
cod INTEGER,
answ CHARACTER VARYING
) AS $BODY$
BEGIN
RETURN QUERY
select 0, 'here goes the message'::CHARACTER VARYING;
END;
$BODY$
LANGUAGE plpgsql;
Upvotes: 1