zoukankan      html  css  js  c++  java
  • 获取月报、季报、半年报,年报等

    CREATE OR REPLACE PROCEDURE INPUT_DATE(NEW_DATE VARCHAR) --YYYYMMDD  VARCHAR
    AS
    D_DATE DATE;
    V_SQL VARCHAR2(200);
    --VAR_DATE VARCHAR2(10)
    BEGIN
     D_DATE := TO_DATE(NEW_DATE,'YYYYMMDD');  --日期格式
     --VAR_DATE = TO_CHAR(D_DATE,'YYYYMMDD')  --字符串格式
     V_SQL := 'INSERT INTO YSY_TEST SELECT :i,D_DATE,:PINDU FROM TABLE_NAME WHERE MODIFY_DATE>= :STARTDATE AND MODIFY_DATE <= :VAR_DATE';
     
       FOR I IN 1..5 LOOP
         IF I = 1 AND D_DATE = TO_CHAR(LAST_DAY(D_DATE),'YYYYMMDD') then  --判断D_DATE是否为月末最后一天
            START_DATE := TO_CHAR(TRUNC(D_DATE,'MM'),'YYYYMMDD');--本月初
            EXECUTE IMMEDIATE V_SQL USING i,D_DATE,START_DATE,D_DATE;
            COMMIT;
         ELSE IF I = 2 AND MOD(TO_NUMBER(TO_CHAR(D_DATE,'MM')),3) = 0  --判断D_DATE是否为3、6、9、12
            AND D_DATE = ADD_MONTHS(TRUNC(D_DATE,'Q'),3)-1 THEN  --判断D_DATE是否为季的最后一天
            START_DATE := TRUNC(D_DATE,'Q');  --季初
            EXECUTE IMMEDIATE V_SQL USING i,NEW_DATE,START_DATE,D_DATE;
            COMMIT;
         ELSE IF I = 3 AND TO_CHAR(D_DATE,'MM') <'07'  --判断是否为上半年
            AND NEW_DATE = ADD_MONTHS(TRUNC(D_DATE,'YYYY'),6)-1 THEN --判断是否为上半年最后一天
            START_DATE := TRUNC(D_DATE,'YYYY');  --上半年初
            EXECUTE IMMEDIATE V_SQL USING i,D_DATE,START_DATE,D_DATE;
            COMMIT;
         ELSE IF I = 4 AND TO_CHAR(D_DATE, 'MM') > '06'  --判断是否为下半年
            AND NEW_DATE = ADD_MONTHS(TRUNC(D_DATE,'YYYY'),12)-1 THEN  --判断是否为下半年最后一天
            START_DATE := ADD_MONTHS(TRUNC(D_DATE,'YYYY'),6);  --下半年初
            EXECUTE IMMEDIATE V_SQL USING i,D_DATE,START_DATE,D_DATE;
            COMMIT;
         ELSE IF I = 5 AND NEW_DATE = ADD_MONTHS(TRUNC(D_DATE,'YYYY'),12)-1 THEN --判断是否为年末最后一天
            START_DATE := TRUNC(D_DATE,'YYYY');  --年初
            EXECUTE IMMEDIATE V_SQL USING i,D_DATE,START_DATE,D_DATE;
            COMMIT;
         END IF;
       END LOOP;
    
    END INPUT_DATE;
  • 相关阅读:
    Java文件流应用:复制文件
    Java IO流之文件流
    初识Java-IO流
    Java集合之Properties
    Java之FilenameFilter接口
    Java之File类
    Java内部类
    Java常用类之要点总结
    Java异常类(Throwable)
    php分布式缓存系统 Memcached 入门
  • 原文地址:https://www.cnblogs.com/yangsy/p/orale_inputdate.html
Copyright © 2011-2022 走看看