plpgsql how to loop record

To loop record inplpgsql postgres you need
to use FOR …. LOOP RETURN NEXT “record” END LOOP

CREATE OR REPLACE FUNCTION __foo(character varying)
  RETURNS SETOF catalog AS
$BODY$
 DECLARE   
   _category ALIAS for $1 ;
   _mytupla record ;
BEGIN

	FOR _mytupla IN (select  * FROM catalog  WHERE "Category" LIKE '%' || _category || '%')    
	LOOP
	   RETURN NEXT _mytupla ;  
	END LOOP ; 
	
END;
$BODY$
  LANGUAGE plpgsql VOLATILE SECURITY DEFINER
  COST 100
  ROWS 1000;
ALTER FUNCTION __foo(character varying) OWNER TO postgres;

..

Risorse:

plpgsql 

Postgresql

Annunci