The mainfunc() returns the refcursor.
CREATE OR REPLACE FUNCTION public.mainfunc() RETURNS refcursor LANGUAGE \'plpgsql\' AS $BODY$ declare ref1 refcurso