【问题标题】:plsql oracle how to not allow for an employee's bonus be greater than 0.1% of the total quantity?plsql oracle如何不允许员工的奖金大于总量的0.1%?
【发布时间】:2012-12-21 21:46:18
【问题描述】:

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

【问题讨论】:

  • 对于初学者来说,0.1% 是* 0.001。你的意思是数量的百分比还是价值的百分比?
  • 库存总值。谢谢你的帮助:)
  • 你能告诉员工表与任何表产品,股票之间的关系

标签: oracle plsql triggers


【解决方案1】:

我猜你的声明有问题,

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

表名被提及为products 而不是product

【讨论】:

  • 您能简要介绍一下您遇到的错误吗?我会尽力帮助你的。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-02-08
  • 2021-02-25
  • 1970-01-01
  • 2021-11-04
  • 1970-01-01
  • 2020-07-24
  • 2016-09-06
相关资源
最近更新 更多