create or replace procedure update_CarryoverArchivers(bizsysname in varchar,

year       in number default 2015) is

begin

declare

num    number;

objSql varchar(1000);

i      number;

begin

num := -1;

select count(*) into num from bd_doc_type where iyear = year;

if num >= 1 then

null;

end if;

if num = 0 then

objSql := 'insert into BD_DOC_TYPE select sdoc_type_code,sdoc_type_name,sshort_text,smudole,' || year ||

',stype,sprinttemplatecode, ''' || year ||

'/01/01 16:51:32'' from BD_DOC_TYPE where iyear=' ||

to_char(year - 1);

/*dbms_output.put_line(objSql);*/

execute immediate objSql;

end if;

num := -1;

select count(*) into num from sm_billtype where iyear = year;

if num >= 1 then

null;

end if;

if num = 0 then

objSql := 'insert into sm_billtype select scode,sname,sbilltypetitle,' || year ||

',''' || year ||

'/12/12 15:03:40'' from sm_billtype where iyear=' ||

to_char(year - 1);

/* dbms_output.put_line(objSql);*/

execute immediate objSql;

end if;

num := -1;

select count(*) into num from bd_fyearstruct_m where iyear = year;

if num >= 1 then

null;

end if;

if num = 0 then

objSql := 'insert into ' || bizsysname || '.BD_FYEARSTRUCT_M (IYEAR, DY_STARTDATE, DY_ENDDATE, IPERIODNUM, BCLOSED, BACTIVEYEAR, TS)

values (' || year || ', ''' || year || '0101'', ''' || year ||

'1231'', 12, ''n'', ''Y'', ''' || year ||

'/01/01 20:33:38'')';

dbms_output.put_line(objSql);

execute immediate objSql;

dbms_output.put_line('xxx');

end if;

num := -1;

i   := 1;

select count(*) into num from bd_fyearstruct_s where iyear = year;

if num >= 1 then

null;

end if;

if num = 0 then

while i <= 12 loop

objSql := ' insert into ' || bizsysname || '.BD_FYEARSTRUCT_S (SPERIODCODE, IYEAR, DP_BEGINDATE, DP_ENDDATE, SPERIODNAME, BCLOSED, BACITVE, TS)

values (''' || year || '-0' || to_char(i) || ''',' || year ||

', ''' || year || '0' || to_char(i) ||

'01'',to_char(add_months(to_date(''' || year || '0' || to_char(i) ||

'01'', ''yyyymmdd''), 1)-1,''yyyymmdd''),''第' || to_char(i) ||

'期'', ''N'', null, ''1999/05/25 11:33:53'') ';

dbms_output.put_line(objSql);

execute immediate objSql;

i := i + 1;

end loop;

end if;

num := -1;

select count(*) into num from sm_billrule where iyear = year;

dbms_output.put_line(num);

if num >= 1 then

null;

end if;

if num = 0 then

objSql := 'insert into sm_billrule select SID, SBILLTYPECODE, BIFSHOWBILLTITLE, BYEAR, BMONTH, BDAY, BIFORDERNUMBER, INUMBERLEN, BIFSHOWOBJID, SPERIODCODE, SCORPCODE,' || year ||

' from sm_billrule where iyear=' || to_char(year - 1);

dbms_output.put_line(objSql);

execute immediate objSql;

end if;

commit;

Exception

When others then

dbms_output.put_line('你出错了'||sqlcode||sqlerrm);

Rollback;

end;

end update_CarryoverArchivers;

---------

存储过程的执行

begin

update_CarryoverArchivers;

end;

最新文章

  1. 时隔一年再读到the star
  2. Python多版本共存之pyenv
  3. [转载]android的消息处理机制(图+源码分析)——Looper,Handler,Message
  4. ShadowGun Deadzone 放出 GM Kit Mod 包
  5. [BZOJ 3564] [SHOI2014] 信号增幅仪 【最小圆覆盖】
  6. [C++ Basic] Const 用法
  7. 201521123111《Java程序设计》第6周学习总结
  8. java 可变參数
  9. BZOJ 2286: [Sdoi2011消耗战 [DP 虚树]
  10. SVN服务器搭建和配置使用详解
  11. Oracle根据符合条件的数据循环批量更新
  12. php中一个&quot;异类&quot;语法: $a &amp;&amp; $b = $c; 【转载】
  13. 图-&gt;连通性-&gt;无向图的连通分量和生成树
  14. mysql的in和not in的用法(特别注意not in结果集中不能有null)
  15. perl hash array 嵌套 push
  16. LY.JAVA面向对象编程.内部类
  17. mysql分组GROUP BY常用sql
  18. 1、JUC--volatile 关键字-内存可见性
  19. 前端框架 Vue 初探
  20. Linux 环境 HTTP 服务器

热门文章

  1. gprof参数说明及常见错误
  2. TYVJ P1048 田忌赛马 Label:dp
  3. COJ986 WZJ的数据结构(负十四)
  4. FlyCapture2 fc2Image OpenCV IplImage Conversion 两种图像格式之间的转换
  5. stringstream 使用方法
  6. 源码安装Postgresql9.4.1
  7. hdu 饭卡
  8. POJ 2892 Tunnel Warfare(线段树单点更新区间合并)
  9. OpenCV学习笔记——视频的边缘检测
  10. Linux 计划任务 Crontab 笔记与总结(5)crontab 常见错误与案例