CREATE OR REPLACE FUNCTION "drugreferencefull"."function6" () RETURNS text AS $body$ DECLARE _generics text; _row record; begin _generics = ''; for _row in SELECT drugreferencefull.manxxdat.product, drugreferencefull.manxxdat.mancode FROM drugreferencefull.manxxdat loop select into _generics drugreferencefull.get_generics(_row.mancode) ; insert into drugreferencefull.manxxdat_generics(mancode,compound_generic) values(_row.mancode,_generics); end loop; return _generics; end $body$ LANGUAGE 'plpgsql' VOLATILE CALLED ON NULL INPUT SECURITY INVOKER;