Hello, I am doing a procedure stored in POSTGRES of type GET. I want to consult the information from this one but it sends me the following error:
CREATE OR REPLACE FUNCTION p.products(_p_id TEXT)
RETURNS TABLE (
_name TEXT
, _total MONEY
, _products SMALLINT) AS $$
BEGIN
RETURN QUERY SELECT row_to_json(t) FROM (SELECT id,
(
SELECT array_to_json(array_agg(row_to_json(d)))
FROM(
SELECT name
, total
, products
) d
) as productss
FROM a.products
WHERE CAST(p_id as TEXT) like _p_id
)t;
END;
$$ LANGUAGE PLPGSQL;
The error he gives me is this:
structure of query does not match function result type