Homework requirement: create a trigger where account must belong to one and only one customer.
My code as shown below doesn't work. Error mesg: quoted string not properly terminated. Please help.
create or replace trigger dupcust
before insert or update on ACCOUNT
for each row
declare
v_ctn NUMBER;
begin
select count(account.cname) into v_ctn from account where A#=:new.A#;
if v_ctn>0 then
raise_application_error (-20107, 'ACCT CAN ONLY BELONG TO ONE CUSTOMER');
end if;
end;
Test code:
UPDATE ACCOUNT SET ACCOUNT.CNAME =’Cook’ WHERE ACCOUNT.A# = ‘1111’;