2008年8月25日星期一

oracle 游标使用 带参数

CURSOR myCursor(DISPACHNO DB_WFS_RPTWFSLIST1.Dispachno%type) is select t.starttime,t.depachdatefrom RPTDATA.DB_WFS_RPTWFSLIST1 twhere t.achivedate between to_date(iStartTime' 00:00:00','YYYY-MM-DD HH24:MI:SS') and to_date(iEndTime' 23:59:59', 'YYYY-MM-DD HH24:MI:SS')and t.dispachno = DISPACHNO;


loop fetch myCursor2 into DISPACHNO; exit when myCursor2%notfound; if myCursor%isopen = false then open myCursor(DISPACHNO); end if;
end loop;close myCursor;

1 条评论:

匿名 说...

这里出了一个非常隐蔽的BUG,参数名字DISPACHNO 好像不能和定义游标外的变量名相同,会出问题.不像C++与JAVA一样.