oracle pl_sql 通過遊標迴圈取數位方法

來源:互聯網
上載者:User
declare  cursor o isselect distinct to_char(report_date,'yyyymmdd') report_date from My_test_DAY_REPORT where report_date >=to_date(20130501,'yyyymmdd') order by 1;  riqi o%rowtype;begin  open o;   loop fetch o    into riqi;  exit when o%notfound;dbms_output.put_line(riqi.report_date);  delete from tmp_no_rijie  where run_date=to_date(riqi.report_date, 'yyyymmdd');  commit;  insert into tmp_no_rijie  select t1.org_code      ,         t1.org_name      ,         t1.org_type_id   ,         t1.org_type_name ,         t1.sup_org_code  ,         t2.org_name      ,         t1.usable       ,         to_date(riqi.report_date, 'yyyymmdd')    from sys_org t1, (select org_name, org_code from sys_org) t2   where org_type_id = 18     and usable = 1     and t1.sup_org_code = t2.org_code     and t1.org_code in (130002,                         150002,                         150057,                         150059,                         150058,                         140023,                         140001,                         110001,                         170006,                         170002,                         180003,                         140024)     and t1.org_code not in         (select org_code            from My_test_DAY_REPORT           WHERE report_date = to_date(riqi.report_date, 'yyyymmdd'));           commit;end loop;close o;end;/
select run_date as 日期,org_code as 組織,org_name as 組織名,'未做日結' from tmp_no_rijie order by 1;
 
 

oracle pl_sql 通過遊標迴圈取數位方法

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.