触发器中我这里游标取值我老是报错,不知道为什么,请帮忙看下~~

driftrabbit 2014-05-09 10:05:57
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;
...全文
141 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
c_sdn_shang_bu_qi 2014-05-13
  • 打赏
  • 举报
回复
sql1:='select V0200 from BusinessSystemRunningTime5MIN1 where resourceid=:id and time=:tm;';-- 将这句改成 sql1:='select V0200 from BusinessSystemRunningTime5MIN1 where resourceid=id and time=tm;';--
babyqian84 2014-05-12
  • 打赏
  • 举报
回复
sql1:='select V0200 from BusinessSystemRunningTime5MIN1 where resourceid=:id and time=:tm;' 把sql1的''里面的分号去掉,看文档应该是不需要的,试试看

17,082

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧