TABLE CREATION:
SQL>create table employee(empname varchar(10),empno number(10),job varchar(10),salary number(10)
SQL>create table employee(empname varchar(10),empno number(10),job varchar(10),salary number(10)
CODING:
SQL>ed trigger
create or replace trigger mysecondtrigger before insert on employee for each row
begin
raise_applicayion_error(-20001,’you cannot insert’);
end;
SQL>@trigger.sql
Trigger created.
SQL>INSERT INTO employee
Values(‘&empname’,&empno,’&job’,&’salary);
Enter value for empname:aaa
Enter value for empno:22
Enter value for job:s/w engg
Enter value for salary:20000
Old 1:insert into employee values(‘&empname’,&empno,’&job’,&’salary);
New 1: insert into employee values(‘aaa’,22,’s/w engg’,20000)
1 row created.
SQL>/
Enter value for empname:bbb
Enter value for empno:25
Enter value for job:s/w engg
Enter value for salary:20000
Old 1:insert into employee values(‘&empname’,&empno,’&job’,&’salary);
New 1: insert into employee values(‘bbb’,25,’s/w engg’,20000)
ERROR at line 1:
ORA-20001:you cannot insert
ORA-06512:at “SCOTT.MYSECONDTRIGGER”,line 2
ORA-04088:error during execution of trigger ‘SCOTT.MYSECONDTRIGEER,
EmoticonEmoticon