By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE
INSERT 0 9
| category | items |
|---|---|
| instruments | accordion|banjo|cor anglais |
SELECT 1
CREATE FUNCTION
ERROR: structure of query does not match function result type DETAIL: Returned type text does not match expected type character varying in column 2. CONTEXT: SQL statement "WITH cte AS ( SELECT category, string_agg(data,'|') AS alldata FROM test WHERE category=selectedcategory GROUP BY category ) SELECT category, alldata FROM cte" PL/pgSQL function doit(character varying) line 2 at RETURN QUERY