postgresql存储过程例子
CREATE OR REPLACE FUNCTION sp_insert_data()
RETURNS integer AS $total$
declare
total integer;
i integer := 1;
BEGIN
insert into tb_test(name) values('name1');
while i < 1000 loop
insert into tb_test(name) values('name1');
i=i+1;
end loop;
SELECT count(*) into total FROM tb_test;
RETURN total;
END;
$total$ LANGUAGE plpgsql;