一、存储过程准备:
1、建立一个空表:
<font size="3">CREATE TABLE test_data ( id NUMBER, name VARCHAR2(50), age NUMBER );
</font>
2、建立一个存储过程:
<font size="3">CREATE OR REPLACE PROCEDURE insert_test_data
(n IN NUMBER) AS
BEGIN
--EXECUTE IMMEDIATE 'truncate table test_data';
FOR i IN 1..n LOOP
INSERT INTO test_data VALUES (i, 'Name' || i, i * 10);
END LOOP;
COMMIT;
END insert_test_data;</font>
3、调试下:
<font size="3">select count(*) from test_data t; call insert_test_data(1000); truncate table test_data;
</font>