--Function: dbo.fn_test(integer)
--DROP FUNCTION dbo.fn_test(integer);
CREATE OR REPLACE FUNCTION dbo.fn_test
(
IN p_count integer = 0
)
RETURNS TABLE
(
id integer,
des text
)
AS
$$
declare
i integer;
top integer;
rec record;
begin
/* Insert real code here */
select into rec * from dbo.a_org_type order by id desc limit 1;
i := rec.id + 1;
top := i + p_count;
while i < top loop
insert into dbo.a_org_type(id, des)
values(i, 'shang hai ' || i);
i:= i+1;
end loop;
return query select * from dbo.a_org_type order by id desc limit 10;
end;
$$
LANGUAGE 'plpgsql';
ALTER FUNCTION dbo.fn_test(integer)
OWNER TO postgres;