plsql - #PLSQL_Trigger duplicate customer doesnt work -
homework requirement: create trigger account must belong 1 , 1 customer.
my code shown below doesn't work. error mesg: quoted string not terminated. please help.
create or replace trigger dupcust before insert or update on account each row declare v_ctn number; begin select count(account.cname) v_ctn account a#=:new.a#; if v_ctn>0 raise_application_error (-20107, 'acct can belong 1 customer'); end if; end;
test code:
update account set account.cname =’cook’ account.a# = ‘1111’;
when copied query, failed due quotes around string cook , 1111. apparently used wrong quote character, corrected quotes , when run query, trigger generates mutation error, answer can can found here:
plsql trigger error. "is mutating, trigger/function may not see it" ora-04091
basically reading table updating, causes mutation, can't that.
a compound trigger, if written correctly, job, example here:
Comments
Post a Comment