oracle触发器以及游标问题
DROPTRIGGERTRG_PMS_GPS_DATA_INS_PILENO;CREATEORREPLACETRIGGERTRG_PMS_GPS_DATA_INS_PIL...
DROP TRIGGER TRG_PMS_GPS_DATA_INS_PILENO;
CREATE OR REPLACE TRIGGER TRG_PMS_GPS_DATA_INS_PILENO AFTER INSERT ON PMS_GPS_DATA FOR EACH ROW
DECLARE
--xx公里
fir_no VARCHAR2(10);
--xx米
sec_no VARCHAR2(10);
--当前桩号到起点距离
loc_ins NUMBER;
--前一个点到起点的距离
pre_gps_ins NUMBER;
--当前点到起点的距离
cur_gps_ins NUMBER;
--前一个点ID
pre_gps_loc_id NUMBER;
CURSOR gps_loc_cursor IS SELECT * FROM GPS_LOC_DATA;
--当前行
gps_loc_row gps_loc_cursor%rowtype;
BEGIN
fir_no := GETSPLITSTR(:new.PILE_NO,'+',0);
sec_no := GETSPLITSTR(:new.PILE_NO,'+',1);
loc_ins := TO_NUMBER(SUBSTR(fir_no,2)) * 1000 + TO_NUMBER(sec_no);
--游标开始
OPEN gps_loc_cursor;
FETCH gps_loc_cursor INTO gps_loc_row;
WHILE gps_loc_cursor%FOUND
loop
pre_gps_ins := cur_gps_ins;
cur_gps_ins := cur_gps_ins + gps_loc_row.LAST_INST;
FETCH gps_loc_cursor INTO gps_loc_row;
END loop;
CLOSE gps_loc_cursor;
END;
我想问问下面这段游标循环有什么问题,把游标这一段删了正常。。。。
FOR gps_loc_row IN gps_loc_cursor loop
cur_gps_loc_id := gps_loc_row.ID;
pre_gps_ins := cur_gps_ins;
cur_gps_ins := cur_gps_ins + gps_loc_row.LAST_INST;
--判断退出条件
IF pre_gps_ins <= loc_ins AND cur_gps_ins >= loc_ins THEN
exit;
END IF;
END loop;
也不行。 展开
CREATE OR REPLACE TRIGGER TRG_PMS_GPS_DATA_INS_PILENO AFTER INSERT ON PMS_GPS_DATA FOR EACH ROW
DECLARE
--xx公里
fir_no VARCHAR2(10);
--xx米
sec_no VARCHAR2(10);
--当前桩号到起点距离
loc_ins NUMBER;
--前一个点到起点的距离
pre_gps_ins NUMBER;
--当前点到起点的距离
cur_gps_ins NUMBER;
--前一个点ID
pre_gps_loc_id NUMBER;
CURSOR gps_loc_cursor IS SELECT * FROM GPS_LOC_DATA;
--当前行
gps_loc_row gps_loc_cursor%rowtype;
BEGIN
fir_no := GETSPLITSTR(:new.PILE_NO,'+',0);
sec_no := GETSPLITSTR(:new.PILE_NO,'+',1);
loc_ins := TO_NUMBER(SUBSTR(fir_no,2)) * 1000 + TO_NUMBER(sec_no);
--游标开始
OPEN gps_loc_cursor;
FETCH gps_loc_cursor INTO gps_loc_row;
WHILE gps_loc_cursor%FOUND
loop
pre_gps_ins := cur_gps_ins;
cur_gps_ins := cur_gps_ins + gps_loc_row.LAST_INST;
FETCH gps_loc_cursor INTO gps_loc_row;
END loop;
CLOSE gps_loc_cursor;
END;
我想问问下面这段游标循环有什么问题,把游标这一段删了正常。。。。
FOR gps_loc_row IN gps_loc_cursor loop
cur_gps_loc_id := gps_loc_row.ID;
pre_gps_ins := cur_gps_ins;
cur_gps_ins := cur_gps_ins + gps_loc_row.LAST_INST;
--判断退出条件
IF pre_gps_ins <= loc_ins AND cur_gps_ins >= loc_ins THEN
exit;
END IF;
END loop;
也不行。 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询