PL SQL trigger using raise_application_error thows error.

旧城冷巷雨未停 提交于 2019-12-20 04:16:42

问题


I have a few things of code I need help debugging but I feel that if I can get one of them running i'll be able to get the rest(oh how i hope).

create or replace 
trigger minimumwage
before insert or update on Employee
for each row
begin
if :new.Wage < 7.25 
then raise_application_error('-20000,Pay is below Texas minimum wage!');
end if;
end;
/

I'm trying to do this on a table ran on my school's server through sqlplus if that helps.


回答1:


When you're getting an error, it's always helpful to specify what error. There is a syntax error in the raise_application_error call in your trigger. That procedure takes two arguments, a number and a string. You are passing in a single argument that is one long string.

create or replace trigger minimumwage
  before insert or update on Employee
  for each row
begin
  if :new.Wage < 7.25 
  then 
    raise_application_error(-20000,'Pay is below Texas minimum wage!');
  end if;
end;

should be valid assuming there is a WAGE column in your EMPLOYEE table.




回答2:


create or replace trigger deny_dec_pu before update of PU on ARTICLE
 for each row
 declare     
 erreur_pu exception;
  begin

     *insert into erreur values ('Operation de MAJ',sysdate);*

      -- this intruction is never executec why ?          

  if (:new.pu < :old.pu) then
  raise erreur_pu ; 
 end if;
 exception 
 when erreur_pu then 
  Raise_application_error(-20100, 'rrrrrrrr', FALSE); 

 end;

/



来源:https://stackoverflow.com/questions/16449225/pl-sql-trigger-using-raise-application-error-thows-error

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!