I need to write a stored procudere like the following:
CREATE OR REPLACE FUNCTION foo() RETURNS TABLE(user_id integer, count bigint) AS $$
some_array integer[];
ret_val __WHAT_TYPE_;
BEGIN
FOR i IN 1 .. array_upper(some_array, 1)
LOOP
//modify the ret_val
END LOOP;
RETURN ret_val;
END $$
LANGUAGE plpgsql;
But I don't know what type of ret_val I should declare?
record