jeudi 27 avril 2017

Trigger after insert with condition in oracle

I have an error with my trigger. it show

LINE/COL ERROR


2/2 PL/SQL: SQL Statement ignored

2/6 PL/SQL: ORA-00922: missing or invalid option

I want this trigger run if the customertype is member.

Here are my table TABLE CUSTOMER

CREATE TABLE CUSTOMER 
(CUSTOMERID VARCHAR2(100) primary key,
CUSTOMERNAME VARCHAR2(50), 
CUSTOMERADDRESS VARCHAR2(100), 
CUSTOMERPHONE VARCHAR2(15), 
CUSTOMEREMAIL VARCHAR2(50), 
CUSTOMERTYPE VARCHAR2(15)
)

TABLE MEMBER

CREATE TABLE MEMBER
(MEMBERID VARCHAR2(100), 
USERNAME VARCHAR2(25), 
PASSWORD VARCHAR2(10), 
CUSTOMERID VARCHAR2(100),
CONSTRAINT FK_Member Foreign Key (CustomerId)
REFERENCES Customer(CustomerId)
);

This is my trigger

CREATE or replace TRIGGER insertMember
after insert ON CUSTOMER
for each row
BEGIN
SET NOCOUNT ON
If (select customertype from customer) = 'member'
begin
  INSERT INTO MEMBER (customerid ) values
  (:new.customerid);

END insertMember;
/

Aucun commentaire:

Enregistrer un commentaire