在PLSQLdeveloper上面执行下列代码时报错 ORA-01008:并非所有变量都已绑定,新手求解, 5
BEGINSELECTbase_cost,base_duration,unit_cost,cost_typeINTOv_costFROMcostcJOINservices...
BEGIN
SELECT base_cost,base_duration,unit_cost,cost_type INTO v_cost FROM cost c JOIN service s ON s.cost_id = c.id AND s.id
= :new.service_id;
IF v_cost.cost_type=2 THEN
SELECT count(*) into v_count FROM month_duration WHERE service_id = :new.service_id AND month_id = TO_CHAR
(:new.logout_time,'yyyymm');
IF v_count>0 THEN
SELECT sofar_duration INTO v_sofar_duration FROM month_duration WHERE service_id = :new.service_id AND month_id =
TO_CHAR(:new.logout_time,'yyyymm');
v_temp_duration:=v_sofar_duration;
v_sofar_duration := v_sofar_duration + :new.duration;
v_duration := v_sofar_duration - v_cost.base_duration*60*60;
IF v_duration > 0 AND v_cost.base_duration*60*60> v_temp_duration THEN
:new.cost := v_cost.unit_cost * v_duration/3600;
ELSIF v_duration > 0 AND v_cost.base_duration*60*60<= v_temp_duration THEN
:new.cost :=v_cost.unit_cost*:new.duration/3600;
END IF;
UPDATE month_duration SET sofar_duration=v_sofar_duration WHERE service_id = :new.service_id AND month_id =
TO_CHAR(:new.logout_time,'yyyymm') ;
ELSE
v_sofar_duration := :new.duration;
INSERT INTO month_duration(service_id,month_id,sofar_duration)
VALUES (:new.service_id,TO_CHAR(:new.logout_time,'yyyymm'),v_sofar_duration);
END IF;
ELSIF v_cost.cost_type=3 THEN
:new.cost :=v_cost.unit_cost*(:new.duration/3600);
END IF;
END; 展开
SELECT base_cost,base_duration,unit_cost,cost_type INTO v_cost FROM cost c JOIN service s ON s.cost_id = c.id AND s.id
= :new.service_id;
IF v_cost.cost_type=2 THEN
SELECT count(*) into v_count FROM month_duration WHERE service_id = :new.service_id AND month_id = TO_CHAR
(:new.logout_time,'yyyymm');
IF v_count>0 THEN
SELECT sofar_duration INTO v_sofar_duration FROM month_duration WHERE service_id = :new.service_id AND month_id =
TO_CHAR(:new.logout_time,'yyyymm');
v_temp_duration:=v_sofar_duration;
v_sofar_duration := v_sofar_duration + :new.duration;
v_duration := v_sofar_duration - v_cost.base_duration*60*60;
IF v_duration > 0 AND v_cost.base_duration*60*60> v_temp_duration THEN
:new.cost := v_cost.unit_cost * v_duration/3600;
ELSIF v_duration > 0 AND v_cost.base_duration*60*60<= v_temp_duration THEN
:new.cost :=v_cost.unit_cost*:new.duration/3600;
END IF;
UPDATE month_duration SET sofar_duration=v_sofar_duration WHERE service_id = :new.service_id AND month_id =
TO_CHAR(:new.logout_time,'yyyymm') ;
ELSE
v_sofar_duration := :new.duration;
INSERT INTO month_duration(service_id,month_id,sofar_duration)
VALUES (:new.service_id,TO_CHAR(:new.logout_time,'yyyymm'),v_sofar_duration);
END IF;
ELSIF v_cost.cost_type=3 THEN
:new.cost :=v_cost.unit_cost*(:new.duration/3600);
END IF;
END; 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询