Hi Guys,
I need some help with creating a simple trigger. I will try to explain the problem i'm having.
I created a table called MEMBER;
SQL> CREATE TABLE MEMBER
2 (MemberID number(7) not null primary key,
3 Surname varchar2(15) not null,
4 Forename varchar2(15) not null,
5 DOB date not null,
6 Street_Name varchar2(20),
7 Town varchar2(20),
8 City varchar2(20),
9 Postcode varchar2(8) not null,
10 Tel_No varchar2(14),
11 Email varchar2(30),
12 Date_Joined date not null,
13 Proof_Of_Residency varchar2(30) not null);
Table Created
--------------------------------------------------------
I then created a test trigger;
TRIGGER
SQL> CREATE OR REPLACE TRIGGER NoSmiths
2 BEFORE INSERT OR UPDATE OF ForeName
3 ON Member
4 FOR EACH ROW
5 BEGIN
6 IF :new.Forename not like '%SMITH%' THEN
7 RAISE_APPLICATION_ERROR(-20000, 'No People Named Smith Allowed!');
8 END IF;
9 END NoSmiths;
10
11 /
------------------------------------------------------------
I then tried to enter some values into the table.
insert into MEMBER
values(0001234, 'Boyd', 'Brandon', '06-AUG-77', '554 Thistlewood Lane', 'Middletown',
'Southampton', 'SO67 6FR', '07986443112', null, '05-DEC-02', 'Received - Gas Bill');
----------------------------------------------------------
But with any values I insert, regardless of the values i get the following error message;
Enter Values
ERROR at line 1:
ORA-20000: No People Named Smith Allowed!
ORA-06512: at "P032452975.NOSMITHS", line 3
ORA-04088: error during execution of trigger 'P032452975.NOSMITHS'
---------------------------------------------------------
What am i doing wrong?
I thought the point of triggers was that if Smith was entered in the forename field then an error message would appear? Otherwise the datbase would accept the values.
If you can help the great, if not, then don't worry.
I need some help with creating a simple trigger. I will try to explain the problem i'm having.
I created a table called MEMBER;
SQL> CREATE TABLE MEMBER
2 (MemberID number(7) not null primary key,
3 Surname varchar2(15) not null,
4 Forename varchar2(15) not null,
5 DOB date not null,
6 Street_Name varchar2(20),
7 Town varchar2(20),
8 City varchar2(20),
9 Postcode varchar2(8) not null,
10 Tel_No varchar2(14),
11 Email varchar2(30),
12 Date_Joined date not null,
13 Proof_Of_Residency varchar2(30) not null);
Table Created
--------------------------------------------------------
I then created a test trigger;
TRIGGER
SQL> CREATE OR REPLACE TRIGGER NoSmiths
2 BEFORE INSERT OR UPDATE OF ForeName
3 ON Member
4 FOR EACH ROW
5 BEGIN
6 IF :new.Forename not like '%SMITH%' THEN
7 RAISE_APPLICATION_ERROR(-20000, 'No People Named Smith Allowed!');
8 END IF;
9 END NoSmiths;
10
11 /
------------------------------------------------------------
I then tried to enter some values into the table.
insert into MEMBER
values(0001234, 'Boyd', 'Brandon', '06-AUG-77', '554 Thistlewood Lane', 'Middletown',
'Southampton', 'SO67 6FR', '07986443112', null, '05-DEC-02', 'Received - Gas Bill');
----------------------------------------------------------
But with any values I insert, regardless of the values i get the following error message;
Enter Values
ERROR at line 1:
ORA-20000: No People Named Smith Allowed!
ORA-06512: at "P032452975.NOSMITHS", line 3
ORA-04088: error during execution of trigger 'P032452975.NOSMITHS'
---------------------------------------------------------
What am i doing wrong?
I thought the point of triggers was that if Smith was entered in the forename field then an error message would appear? Otherwise the datbase would accept the values.
If you can help the great, if not, then don't worry.