plsql oracle如何不允许员工的奖金超过总数的0.1%?

plsql oracle如何不允许员工的奖金超过总数的0.1%?,oracle,plsql,triggers,Oracle,Plsql,Triggers,我是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.Qu

我是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;

我想你的申报有问题

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

表名被称为产品,而不是产品

对于初学者,0.1%为*0.001。你指的是数量的%还是价值的美元?股票的总价值。感谢您的帮助:您能告诉我employee表与任何一种表产品之间的关系吗?Stock您能简要介绍一下您得到的错误吗?我会尽力帮你的。