Oracle之带参存储过程(存储过程中for循环调用存储过程)

一段业务代码改编,大概意思是搜索指定时间段内的信息,未详细说明业务内容,仅供参考几个参数的位置。

--带参存储过程 testdate,参数为v,内部定义参数i
create
or replace procedure testdate(v in number) is i number; begin i:=v; --v赋值给i
select EN_ID,EN_NAME,ASA_CODE,ASA_NAME,AS_YESTERDAY,DATEKEEY from test2table where datekeey = i; commit; end testdate;
--存储过程中for循环调用存储过程,testdate2调用testdate
create
or replace procedure testdate2 is Cursor datekeey is
select to_number(to_char(datekeey,'yyyyMMdd')) datekeey from ( select date'2017-01-01' + (rownum - 1) datekeey from dual connect by rownum <= (date'2018-09-18' - date'2017-01-01' + 1) ); --从2017-01-01到2018-09-18遍历日期 i number; begin for i in datekeey LOOP begin testdate(i.datekeey); --调用testdate存储过程 end; end LOOP; commit; end testdate2;
原文地址:https://www.cnblogs.com/schoolbag/p/9674776.html