【问题标题】:how to run stored procedure in oracle with loop如何在oracle中使用循环运行存储过程
【发布时间】:2020-10-11 22:21:16
【问题描述】:

我想通过匿名块调用程序,例如 开始 t_maha_del_22_06_p('22.06.2020');结束; 但我运行一次并希望使用循环调用以占用大量日期时间 就像从 8 月 1 日到 15 日一样。我该怎么做?


create table t_maha_delete_22_06
(dt date,text varchar2(100));


create or replace procedure my_sch.t_maha_del_22_06_p(p_dt in date default trunc(sysdate) -1) as
begin
delete from t_maha_delete_22_06
where trunc(dt) = p_dt;
commit;

insert into t_maha_delete_22_06
select 
trunc(p_dt) dt,
'blablabla' text from dual 
commit;
end;

【问题讨论】:

    标签: oracle loops plsql cursor procedure


    【解决方案1】:

    您可以按如下方式循环执行:

    begin 
    For dt in (select date '2020-08-01' + level - 1 as dates
               From dual 
               Connect by level <= date '2020-08-15' - date '2020-08-01')
    Loop
    t_maha_del_22_06_p(dt.dates);
    End loop;
    end; 
    /
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-04-10
      • 1970-01-01
      • 2011-03-09
      • 1970-01-01
      • 2016-12-03
      • 1970-01-01
      • 2019-02-02
      相关资源
      最近更新 更多