I am trying to create a PostgreSQL function where I will loop over the rows of a query and store some of them in an array, before doing more stuff with it. How can I create an array of rowtype?
CREATE OR REPLACE FUNCTION forExample() RETURNS integer AS
$BODY$
DECLARE
r "WEBHOST"%rowtype;
b "WEBHOST"%rowtype[]; <- This does not work !!!
BEGIN
FOR r IN SELECT * FROM "WEBHOST"
LOOP
array_append(b, r);
END LOOP;
RETURN 33;
END
$BODY$
LANGUAGE 'plpgsql';
The above function will be more complex, but I am providing a simplified version for this question.