这是我得到的错误
ORA-24344: success with compilation error
这是我的代码:
create or replace trigger TRG_AFTER_INSERT
AFTER INSERT ON TBLORDERCHARGES
FOR EACH ROW
DECLARE W_CHARGETYPE VARCHAR2(1);
W_CHARGEAMOUNT NUMBER;
W_DISCOUNTPERCENT NUMBER;
Begin
SELECT fldPartServiceType
INTO W_CHARGETYPE
FROM TBLPARTSSERVICES
WHERE fldPartServiceId = :new.fldChargeCode;
SELECT fldPartServiceAmount
INTO W_CHARGEAMOUNT
FROM TBLPARTSSERVICES
WHERE fldPartServiceId = :new.fldChargeCode;
SELECT fldDiscountPercent
INTO W_DISCOUNTPERCENT
FROM TBLPARTSSERVICES
WHERE fldPartServiceId = :new.fldChargeCode;
UPDATE TBLORDERCHARGES
SET fldChargeType = W_CHARGETYPE,
fldChargeAmount = W_CHARGEAMOUNT,
fldDiscountPercent = W_DISCOUNTPERCENT
WHERE fldChargeId = :new.fldChargeId;
END;
我也尝试过这段代码,但结果相同:
create or replace trigger TRG_AFTER_INSERT
AFTER INSERT ON TBLORDERCHARGES
FOR EACH ROW
DECLARE
W_CHARGETYPE AS VARCHAR(1);
W_CHARGEAMOUNT AS NUMBER;
W_DISCOUNTPERCENT AS NUMBER;
Begin
W_CHARGETYPE = (SELECT fldPartServiceType FROM tblPartsServices
WHERE fldPartServiceId = :new.fldChargeCode);
W_CHARGEAMOUNT = (SELECT fldPartServiceAmount FROM tblPartsServices
WHERE fldPartServiceId = :new.fldChargeCode);
W_DISCOUNTPERCENT = (SELECT fldDiscountPercent FROM tblPartsServices
WHERE fldPartServiceId = :new.fldChargeCode);
UPDATE tblOrderCharges
SET fldChargeType = W_CHARGETYPE,
fldChargeAmount = W_CHARGEAMOUNT,
fldDiscountPercent = W_DISCOUNTPERCENT,
WHERE fldChargeId = :new.fldChargeId;
END;
以及这段代码,没有任何运气:
create or replace trigger TRG_AFTER_INSERT
AFTER INSERT ON TBLORDERCHARGES
FOR EACH ROW
Begin
UPDATE tblOrderCharges AS OC
SET fldChargeType = (SELECT fldPartServiceType FROM tblPartsServices AS PS
WHERE PS.fldPartServiceId = OC.fldChargeCode),
fldChargeAmount = (SELECT fldPartServiceAmount FROM tblPartsServices AS PS
WHERE PS.fldPartServiceId = OC.fldChargeCode),
fldDiscountPercent = (SELECT fldDiscountPercent FROM tblPartsServices AS PS
WHERE PS.fldPartServiceId = OC.fldChargeCode),
WHERE fldChargeId = :new.fldChargeId;
END;
我试过的最后一个代码,非常沮丧:
create or replace trigger TRG_AFTER_INSERT
AFTER INSERT ON TBLORDERCHARGES
FOR EACH ROW
DECLARE
W_PARTSERVICE_AMOUNT NUMBER;
W_PARTSERVICE_DISCOUNT NUMBER;
W_CHARGE_AMOUNT NUMBER;
W_PARTSERVICE_ID VARCHAR2(10);
W_PARTSERVICE_TYPE VARCHAR2(1);
W_CHARGE_ID NUMBER;
W_CHARGE_CODE VARCHAR2(10);
W_CHARGE_TYPE VARCHAR2(1);
W_CHARGE_REMARKS VARCHAR2(40);
W_CHARGE_STATUS VARCHAR2(1);
W_CHARGE_ORDER_ID VARCHAR2(10);
W_TECHNICIAN_ID VARCHAR2(10);
SELECT fldChargeId, fldChargeCode, fldChargeType, fldRemarks, fldChargeStatus, fldOrderId, fldTechnicianId
INTO W_CHARGE_ID, W_CHARGE_CODE, W_CHARGE_TYPE, W_CHARGE_REMARKS, W_CHARGE_STATUS, W_CHARGE_ORDER_ID, W_TECHNICIAN_ID
FROM tblOrderCharges
WHERE fldChargeId = :new.fldChargeId
SELECT fldPartServiceAmount, fldPartServiceType, fldDiscountPercent
INTO W_PARTSERVICE_AMOUNT, W_PARTSERVICE_TYPE, W_PARTSERVICE_DISCOUNT
FROM tblPartsServices
WHERE fldPartServiceId = W_CHARGE_CODE
Begin
UPDATE tblOrderCharges
SET fldChargeAmount = W_PARTSERVICE_AMOUNT,
fldChargeType = W_PARTSERVICE_TYPE,
fldDiscountPercent = W_PARTSERVICE_DISCOUNT
WHERE fldChargeId = W_CHARGE_ID;
END;
我不明白为什么oracle对代码错误不具体。它变得令人沮丧。我被困在这里,不确定我做错了什么。
答案 0 :(得分:0)
rewrited
create or replace trigger TRG_AFTER_INSERT
AFTER INSERT ON TBLORDERCHARGES
FOR EACH ROW
DECLARE
W_CHARGETYPE VARCHAR2(1);
W_CHARGEAMOUNT NUMBER;
W_DISCOUNTPERCENT NUMBER;
Begin
SELECT fldPartServiceType
INTO W_CHARGETYPE
FROM TBLPARTSSERVICES
WHERE fldPartServiceId = :new.fldChargeCode;
SELECT fldPartServiceAmount
INTO W_CHARGEAMOUNT
FROM TBLPARTSSERVICES
WHERE fldPartServiceId = :new.fldChargeCode;
SELECT fldDiscountPercent
INTO W_DISCOUNTPERCENT
FROM TBLPARTSSERVICES
WHERE fldPartServiceId = :new.fldChargeCode;
:new.fldChargeType = W_CHARGETYPE;
:new.fldChargeAmount = W_CHARGEAMOUNT;
:new.fldDiscountPercent = W_DISCOUNTPERCENT;
END