1

我是 sql 新手,想知道是否有人可以帮助我使用触发器调试我的 sql 查询。

我想要做的是不允许员工的奖金超过他们负责的股票总量的 0.1%。谁能帮帮我吗?

我的代码如下:

create or replace trigger check_employee_bonus
before update of Bonus or insert on employee
for each row
Declare
Max_Bonus   products.Quantity%TYPE;     
begin
select st.Quantity * 0.1
INTO MaxBonus
from product p, Stock st
Where
p.warehousenum = st.W_no
AND
p.p_no = st.p_no;
if :new.Bonus > Max_Bonus then
RAISE_APPLICATION_ERROR(-20512, 'sales rep’s yearly bonus may not exceed 0.1%  . ');
end if;
end;
4

1 回答 1

0

I guess there is a problem with your declaration,

Declare
Max_Bonus   products.Quantity%TYPE; ********* it should be product.Quantity      
begin
select st.Quantity * 0.1

Table name is mentioned as products instead of product

于 2012-12-22T02:10:31.977 回答