触发器中小弟我这里游标取值小弟我老是报错,不知道为什么,请帮忙看下~
触发器中我这里游标取值我老是报错,不知道为什么,请帮忙看下~~
create or replace trigger TR_bsRunningTime5MIN
before update on BusinessSystemRunningTime5MIN
for each row
declare
-- local variables here
old_value number;
tr_minute number;
--new_value number;
sql1 varchar2(320);
tr_vtime_now varchar2(8);
tr_vtime_bf varchar2(8);
v_cnt number;
-- new_row BusinessSystemRunningTime5MIN%rowtype;
TYPE VCurTyp IS REF CURSOR;
v_cursor VCurTyp;
-- v_cursor2 number;
pragma autonomous_transaction;
begin
sql1:='select V0200 from BusinessSystemRunningTime5MIN1 where resourceid=:id and time=:tm;';--这里一定要用这
--种方式因为V0200是合成的字符串,这里省略了代码
OPEN v_cursor FOR sql1 USING :new.resourceid,:new.time;--************在这里提示无效字符
tr_minute:=to_char(sysdate,'mi')-mod((to_char(sysdate,'mi')),5);
if --判断分钟是否为2位数,若为1位数,则前面加个0
length(tr_minute)=1
then
tr_minute:='0'||tr_minute;
end if;
tr_vtime_now:='V'||to_char(sysdate,'hh24')||tr_minute;
CLOSE v_cursor;
case when tr_vtime_now='V0000' then if old_value>:new.V0000 Then select count(*) INTO v_cnt from plantable where resourceid=:NEW.resourceid and sysdate between begintime and endtime; if v_cnt=0 then :new.V0000:=old_value+300; end if; if v_cnt!=0 then null; end if; end if;
else
null;
end case;
end TR_bsRunningTime5MIN;
------解决方案--------------------
sql1:='select V0200 from BusinessSystemRunningTime5MIN1 where resourceid=:id and time=:tm;'
把sql1的''里面的分号去掉,看文档应该是不需要的,试试看
------解决方案--------------------
sql1:='select V0200 from BusinessSystemRunningTime5MIN1 where resourceid=:id and time=:tm;';--
将这句改成
sql1:='select V0200 from BusinessSystemRunningTime5MIN1 where resourceid=id and time=tm;';--
create or replace trigger TR_bsRunningTime5MIN
before update on BusinessSystemRunningTime5MIN
for each row
declare
-- local variables here
old_value number;
tr_minute number;
--new_value number;
sql1 varchar2(320);
tr_vtime_now varchar2(8);
tr_vtime_bf varchar2(8);
v_cnt number;
-- new_row BusinessSystemRunningTime5MIN%rowtype;
TYPE VCurTyp IS REF CURSOR;
v_cursor VCurTyp;
-- v_cursor2 number;
pragma autonomous_transaction;
begin
sql1:='select V0200 from BusinessSystemRunningTime5MIN1 where resourceid=:id and time=:tm;';--这里一定要用这
--种方式因为V0200是合成的字符串,这里省略了代码
OPEN v_cursor FOR sql1 USING :new.resourceid,:new.time;--************在这里提示无效字符
tr_minute:=to_char(sysdate,'mi')-mod((to_char(sysdate,'mi')),5);
if --判断分钟是否为2位数,若为1位数,则前面加个0
length(tr_minute)=1
then
tr_minute:='0'||tr_minute;
end if;
tr_vtime_now:='V'||to_char(sysdate,'hh24')||tr_minute;
CLOSE v_cursor;
case when tr_vtime_now='V0000' then if old_value>:new.V0000 Then select count(*) INTO v_cnt from plantable where resourceid=:NEW.resourceid and sysdate between begintime and endtime; if v_cnt=0 then :new.V0000:=old_value+300; end if; if v_cnt!=0 then null; end if; end if;
else
null;
end case;
end TR_bsRunningTime5MIN;
------解决方案--------------------
sql1:='select V0200 from BusinessSystemRunningTime5MIN1 where resourceid=:id and time=:tm;'
把sql1的''里面的分号去掉,看文档应该是不需要的,试试看
------解决方案--------------------
sql1:='select V0200 from BusinessSystemRunningTime5MIN1 where resourceid=:id and time=:tm;';--
将这句改成
sql1:='select V0200 from BusinessSystemRunningTime5MIN1 where resourceid=id and time=tm;';--