drop type tp09_1; create type tp09_1 as (num integer, data text); create or replace function f09_1(text, integer, integer) returns setof tp09_1 as $$ declare ret tp09_1; begin for i in $2 .. $2 + $3 - 1 loop if i = 10000 then raise exception '範囲を越えました!'; end if; ret.num := i; ret.data := $1 || to_char(i, 'FM0000'); return next ret; end loop; return; end; $$ language plpgsql;