CREATE TRIGGER copy_people_to_employee
AFTER INSERT ON TEST_PEOPLE
FOR EACH ROW
BEGIN
INSERT INTO TEST_EMPLOYEE (TE_ID,TE_NAME,TE_DATE)
VALUES (P_ID.NEXTVAL,TEST_PEOPLE.P_NAME,SYSDATE)
end;
其中表TEST_PEOPLE和表TEST_EMPLOYEE已经建好了。
但是运行语句的时候出错了。
ERROR line 7, col 1, ending_line 7, ending_col 3, Found 'end', Expecting: RETURN RETURNING or LOG or ;
------解决方案--------------------
CREATE TRIGGER copy_people_to_employee
AFTER INSERT ON TEST_PEOPLE
FOR EACH ROW
BEGIN
INSERT INTO TEST_EMPLOYEE (TE_ID,TE_NAME,TE_DATE)
VALUES (P_ID.NEXTVAL,:new.P_NAME,SYSDATE);
end;
------解决方案--------------------
目测楼主少了一个分号
- SQL code
INSERT INTO TEST_EMPLOYEE (TE_ID,TE_NAME,TE_DATE) VALUES (P_ID.NEXTVAL,TEST_PEOPLE.P_NAME,SYSDATE)改成INSERT INTO TEST_EMPLOYEE (TE_ID,TE_NAME,TE_DATE) VALUES (P_ID.NEXTVAL,TEST_PEOPLE.P_NAME,SYSDATE);