此过程代码用于对新插件应用折扣。我遇到的问题是正在获取太多记录。我将如何解决这个问题?我使用触发器还是函数?
好的,我已经创建了一个触发器,但我得到了 PLS-00103:在预期以下情况之一时遇到符号“=”::=。(@%;
CREATE OR REPLACE PROCEDURE CHECK_DISCOUNT
AS
V_COUNT NUMBER;
V_C_NO APPOINTMENT.C_NO%TYPE;
V_BILL APPOINTMENT.BILL%TYPE;
BEGIN
SELECT C_NO,COUNT(C_NO)
INTO V_C_NO,V_COUNT
FROM APPOINTMENT
GROUP BY C_NO;
SELECT BILL
INTO V_BILL
FROM APPOINTMENT;
IF V_COUNT=3 THEN
V_BILL:=V_BILL * 0.9;
END IF;
UPDATE APPOINTMENT
SET BILL = V_BILL
WHERE C_NO=:new.C_NO;
COMMIT;
END;
/
Create or replace TRIGGER CHECK_DISCOUNT
BEFORE INSERT OR UPDATE OF C_NO ON APPOINT
FOR EACH ROW
DECLARE CURSOR C_APPTMENT IS
SELECT C_NO,COUNT(C_NO)
FROM APPOINTMENT GROUP BY C_NO;
VISIT NUMBER; V_C_NO APPOINTMENT.C_NO%TYPE;
V_BILL APPOINTMENT.BILL%TYPE;
V_TEN NUMBER(3):=0.9;
BEGIN
LOOP
OPEN C_APPTMENT; FETCH C_APPTMENT INTO V_C_NO, VISIT;
EXIT WHEN C_APPTMENT%NOTFOUND;
SELECT BILL INTO V_BILL FROM APPOINTMENT;
IF VISITS =3 THEN V_BILL=V_BILL * V_TEN
WHERE :NEW.C_NO=V_C_NO;
UPDATE APPOINTMENT SET BILL:= V_BILL
WHERE:NEW.C_NO=V_C_NO;
END LOOP;
CLOSE C_APPTMENT;
结尾;