Postgresql – SQL Error [42804]: ERROR: structure of query does not match function result type
CREATE OR REPLACE FUNCTION display_columns_data(table_name varchar, columns_to_display varchar[]) RETURNS TABLE (result_row json) AS $$ BEGIN RETURN QUERY EXECUTE 'SELECT ' || array_to_string(columns_to_display, ',') || ' FROM ' || table_name; END; $$ LANGUAGE plpgsql; SELECT * FROM display_columns_data('employees', ARRAY['first_name', 'last_name']); Detail:…