码迷,mamicode.com
首页 > 其他好文 > 详细

会计日历-自动生成脚本

时间:2015-07-03 20:42:42      阅读:223      评论:0      收藏:0      [点我收藏+]

标签:

技术分享

 

--自动生成当前年份所有月的会计期间

--Parameters:

--:YEAR  当前年份

--:TYPE  会计日历类型

    SELECT INITCAP (TO_CHAR (TO_DATE (ROWNUM, ‘MM‘), ‘MON‘)) PREFIX,

           :TYPE TYPE,

           :YEAR YEAR,

           TO_CHAR (TO_DATE (ROWNUM, ‘MM‘), ‘q‘) QUARTER,

           ROWNUM NUM,

           ( :YEAR || ‘-‘ || ROWNUM || ‘-01‘) FROM_DAY,

           TO_CHAR (LAST_DAY (TO_DATE ( :YEAR || ‘-‘ || ROWNUM, ‘YYYY-MM‘)), ‘YYYY-MM-DD‘) TO_DAY,

           INITCAP (TO_CHAR (TO_DATE (ROWNUM || ‘-‘ || :YEAR, ‘MM-YYYY‘), ‘MON-YYYY‘)) NAME

      FROM DUAL

CONNECT BY ROWNUM <= 12

UNION ALL

SELECT ‘Adj‘ PREFIX,

       :TYPE TYPE,

       :YEAR YEAR,

       ‘4‘ QUARTER,

       13 NUM,

       TO_CHAR (LAST_DAY (TO_DATE ( :YEAR || ‘-‘ || ‘12‘, ‘YYYY-MM‘)), ‘YYYY-MM-DD‘) FROM_DAY,

       TO_CHAR (LAST_DAY (TO_DATE ( :YEAR || ‘-‘ || ‘12‘, ‘YYYY-MM‘)), ‘YYYY-MM-DD‘) TO_DAY,

       ‘Adj-‘ || :YEAR NAME

  FROM DUAL;

 

 

--Dataload template

    SELECT INITCAP (TO_CHAR (TO_DATE (ROWNUM, ‘MM‘), ‘MON‘)) PREFIX,

           ‘TAB‘ KEY,

           :TYPE TYPE,

           ‘TAB‘ KEY,

           :YEAR YEAR,

           ‘TAB‘ KEY,

           TO_CHAR (TO_DATE (ROWNUM, ‘MM‘), ‘q‘) QUARTER,

           ‘TAB‘ KEY,

           ROWNUM NUM,

           ‘TAB‘ KEY,

           ( :YEAR || ‘-‘ || ROWNUM || ‘-01‘) FROM_DAY,

           ‘TAB‘ KEY,

           TO_CHAR (LAST_DAY (TO_DATE ( :YEAR || ‘-‘ || ROWNUM, ‘YYYY-MM‘)), ‘YYYY-MM-DD‘) TO_DAY,

           ‘TAB‘ KEY,

           INITCAP (TO_CHAR (TO_DATE (ROWNUM || ‘-‘ || :YEAR, ‘MM-YYYY‘), ‘MON-YYYY‘)) NAME,

           ‘TAB‘ KEY,

           ‘\^{DOWN}‘ KEY

      FROM DUAL

CONNECT BY ROWNUM <= 12

UNION ALL

SELECT ‘Adj‘ PREFIX,

       ‘TAB‘ KEY,

       :TYPE TYPE,

       ‘TAB‘ KEY,

       :YEAR YEAR,

       ‘TAB‘ KEY,

       ‘4‘ QUARTER,

       ‘TAB‘ KEY,

       13 NUM,

       ‘TAB‘ KEY,

       TO_CHAR (LAST_DAY (TO_DATE ( :YEAR || ‘-‘ || ‘12‘, ‘YYYY-MM‘)), ‘YYYY-MM-DD‘) FROM_DAY,

       ‘TAB‘ KEY,

       TO_CHAR (LAST_DAY (TO_DATE ( :YEAR || ‘-‘ || ‘12‘, ‘YYYY-MM‘)), ‘YYYY-MM-DD‘) TO_DAY,

       ‘TAB‘ KEY,

       ‘Adj-‘ || :YEAR NAME,

       ‘TAB‘ KEY,

       ‘*SB‘ KEY

  FROM DUAL;

会计日历-自动生成脚本

标签:

原文地址:http://www.cnblogs.com/quanweiru/p/4619491.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!