I'm trying to do my first Function in PostgreSQL, but I can't to do it. I was write this piece of code
CREATE OR REPLACE FUNCTION getCars () RETURNS TABLE ( car_name VARCHAR, id_car INT ) AS $$ BEGIN RETURN QUERY SELECT brand,car_id FROM cars; end; $$ LANGUAGE plpgsql;
But... The error is when I'm trying to call taht function:
Where is the issue?
the error message it's:
SQL Error : ERROR: structure of query does not match function result type Detail: Returned type text does not match expected type character varying in column 1. Where: PL/pgSQL function getcars() line 3 at RETURN QUERY
Thanks in advance!