gpt4 book ai didi

sql - 使用找不到的编译错误创建的触发器?

转载 作者:行者123 更新时间:2023-12-03 08:23:22 26 4
gpt4 key购买 nike

使用触发功能的组合自动监视最小库存水平,以触发提醒消息。

这是一项学习练习,并尝试使用stackoverflow的所有帮助对其进行更改,但似乎不想继续工作。

创建了以下语法:

CREATE OR REPLACE TRIGGER STOCKqtyCheck
AFTER INSERT OR UPDATE OF QTY ON STOCK
DECLARE

MINIMUM_QTY NUMBER
QTY NUMBER
STOCK_LOW_Error EXCEPTION;
BEGIN
SELECT count(*)
/* THE COUNT WILL LOOK INTO QTY */
INTO QTY
FROM STOCK.MINIMUM_QTY
WHERE
/* WHERE MINIMUM QTY IS LESS THAN QTY */
'MINIMUM_QTY' <= 'QTY'
IF STOCK_LOW_Error < 'MINIMUM_QTY' THEN
RAISE STOCK_LOW_Error;
END IF;
EXCEPTION
WHEN STOCK_LOW_Error THEN
Raise_Application_Error ('STOCK LEVEL TO LOW Error'));
END;
/

SQL输出:
SQL> CREATE OR REPLACE TRIGGER STOCKqtyCheck
2 AFTER INSERT OR UPDATE OF QTY ON STOCK
3
4 DECLARE
5
6 MINIMUM_QTY NUMBER
7 QTY NUMBER
8 STOCK_LOW_Error EXCEPTION;
9
10 BEGIN
11 SELECT count(*)
12 /* THE COUNT WILL LOOK INTO QTY */
13 INTO QTY
14 FROM STOCK.MINIMUM_QTY
15 WHERE
16 /* WHERE MINIMUM QTY IS LESS THAN QTY */
17 'MINIMUM_QTY' <= 'QTY'
18
19 IF STOCK_LOW_Error < 'MINIMUM_QTY' THEN
20 RAISE STOCK_LOW_Error;
21 END IF;
22
23 EXCEPTION
24 WHEN STOCK_LOW_Error THEN
25 Raise_Application_Error ('STOCK LEVEL TO LOW Error'));
26 END;
27 /

Warning: Trigger created with compilation errors.

编译错误是什么?我检查了它们所在的表并正确创建,所有外键和主键也都正确存在,包括字段数据类型以及如何将下面的光标嵌入到触发器中?
CURSOR Stock_count
IS
SELECT QTY,MINIMUM_QTY
FROM STOCK;

最佳答案

What are the compilation errors?



在SQL * Plus中触发编译错误:
SQL> show errors trigger stockqtycheck

有关其他工具,请参阅该工具的用户手册。

至少您缺少几个分号 ;

关于sql - 使用找不到的编译错误创建的触发器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20321807/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com