create table sample_data (
id number(10,0) generated as identity,
info varchar2(100),
created_by number(10,0) not null,
created_date timestamp(6) not null,
modified_by number(10,0) not null,
modified_date timestamp(6) not null,
ver number(10,0) not null,
primary key (id)
);
CREATE OR REPLACE PROCEDURE CREATE_SAMPLE_DATA(v_info IN VARCHAR2) AS
v_user_id sample_data.created_by%TYPE := 3;
BEGIN
FOR i IN 1..100 LOOP
INSERT INTO sample_data (
info, created_by, created_date, modified_by, modified_date, ver
) VALUES (
v_info || ':' || i, v_user_id, CURRENT_TIMESTAMP, v_user_id, CURRENT_TIMESTAMP, 0
);
END LOOP;
COMMIT;
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE(
'SQLCODE: ' || SQLCODE || ' SQLERRM: ' || SQLERRM);
ROLLBACK;
RAISE;--呼出し元へのエラー伝達
END CREATE_SAMPLE_DATA;