我在创建以下触发器时遇到错误:有任何线索如何解决?
13 32 PLS-00103:遇到下列情况之一时遇到符号“WHEN”:. (* @%& = - +< /> at in是mod的余数不是rem然后<>或!=或〜=> =< =<>和/或类似
create or replace trigger "CONVEYANCE_REQUEST_T3"
BEFORE
insert or update on "CONVEYANCE_REQUEST"
for each row
begin
CASE
when :NEW.REGULAR_TRAVEL_MODE = '2 WHEELER' THEN
BEGIN
CASE
when :NEW.WAY_TYPE = 'ONE WAY' THEN
SELECT RATE_PER_KM * :NEW.REGULAR_DISTANCE_ONEWAY * 1 INTO :NEW.REGULAR_AMOUNT FROM CONVEYANCE_RATE WHERE TRAVEL_MODE = :NEW.REGULAR_TRAVEL_MODE;
WHEN :NEW.WAY_TYPE ='TWO WAY' THEN
SELECT RATE_PER_KM * :NEW.REGULAR_DISTANCE_ONEWAY * 2 INTO :NEW.REGULAR_AMOUNT FROM CONVEYANCE_RATE WHERE TRAVEL_MODE = :NEW.REGULAR_TRAVEL_MODE;
END CASE;
END;
when :NEW.REGULAR_TRAVEL_MODE WHEN = '4 WHEELER' THEN
BEGIN
CASE
when :NEW.WAY_TYPE = 'ONE WAY' THEN
SELECT RATE_PER_KM * :NEW.REGULAR_DISTANCE_ONEWAY * 1 INTO :NEW.REGULAR_AMOUNT FROM CONVEYANCE_RATE WHERE TRAVEL_MODE = :NEW.REGULAR_TRAVEL_MODE;
WHEN :NEW.WAY_TYPE ='TWO WAY' THEN
SELECT RATE_PER_KM * :NEW.REGULAR_DISTANCE_ONEWAY * 2 INTO :NEW.REGULAR_AMOUNT FROM CONVEYANCE_RATE WHERE TRAVEL_MODE = :NEW.REGULAR_TRAVEL_MODE;
END CASE;
END;
END CASE;
END;
答案 0 :(得分:1)
你不能some_variable := (SELECT some_column FROM ...)
。而是在查询中执行所有计算并使用SELECT ... INTO
分配结果。例如,以下是如何对:NEW.REGULAR_AMOUNT
进行第一次分配:
SELECT RATE_PER_KM * :NEW.REGULAR_DISTANCE_ONEWAY * 1
INTO :NEW.REGULAR_AMOUNT
FROM CONVEYANCE_RATE ...
我会留给你处理其余的案件。
答案 1 :(得分:0)
以下行还有其他时间..
when :NEW.REGULAR_TRAVEL_MODE WHEN = '4 WHEELER' THEN
尝试以下代码
when :NEW.REGULAR_TRAVEL_MODE = '4 WHEELER' THEN