使用 raise_application_error 的 PL SQL 触发器显示错误。

use*_*828 1 sql plsql sqlplus

我有一些代码需要帮助调试,但我觉得如果我能让其中一个运行,我就能得到其余的(哦,我多么希望)。

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;
/
Run Code Online (Sandbox Code Playgroud)

如果有帮助,我正在尝试在通过 sqlplus 在我学校服务器上运行的表上执行此操作。

Jus*_*ave 5

当您遇到错误时,指定什么错误总是有帮助的。raise_application_error触发器中的调用存在语法错误。该过程需要两个参数,一个数字和一个字符串。您传入的是一个长字符串的单个参数。

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;
Run Code Online (Sandbox Code Playgroud)

假设WAGE你的EMPLOYEE表中有一个列应该是有效的。