`
tangkuo
  • 浏览: 101078 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
文章分类
社区版块
存档分类
最新评论

oracle

 
阅读更多
CREATE OR REPLACE PROCEDURE PROC_DAY_OVER_CALCULATE AS
  V_DAY_IDX                   DATE;
  V_COUNT                     NUMBER;
  V_ORDER_ID                  VARCHAR2(50);
  V_PAYMENT_ORDER_NO          VARCHAR2(50);
  V_ACCOUNT_NO                NUMBER(16);
  V_SUBJECT_DR_CR             VARCHAR2(4);
  V_CASH_AMOUNT               NUMBER;
  V_FREEZE_AMOUNT             NUMBER;
  V_OVERDRAFT_AMOUNT_LIMIT    NUMBER;
  V_CUR_DR_AMOUNT             NUMBER;
  V_CUR_CR_AMOUNT             NUMBER;
  V_DR_AMOUNT                 NUMBER;
  V_CR_AMOUNT                 NUMBER;
  V_YESTODAY_CASH_AMOUNT      NUMBER;
  V_YESTODAY_FREEZE_AMOUNT    NUMBER;
  V_YESTODAY_OVERDRAFT_AMOUNT NUMBER;
  V_YESTODAY_DR_AMOUNT        NUMBER;
  V_YESTODAY_CR_AMOUNT        NUMBER;
  V_TEMP_BALANCE              NUMBER;
  V_ACCRUAL                   NUMBER;
  V_SQL                       VARCHAR2(255);
  V_ERRTEXT                   VARCHAR2(255);
  V_ADJUST                    NUMBER;
  CURSOR CUR_ACC_DR_CR(V_DAY_IDX DATE) IS
    SELECT T.ORDER_ID,
           R.ACCOUNT_NO,
           R.PAYMENT_ORDER_NO,
           R.DR_TOTAL,
           R.CR_TOTAL
      FROM (SELECT T_ACCOUNT_WATER.PAYMENT_ORDER_NO,
                   T_ACCOUNT_WATER.ACCOUNT_NO,
                   SUM(CASE T_ACCOUNT_WATER.DR_CR_FLAG
                         WHEN 'DR' THEN
                          T_ACCOUNT_WATER.DR_CR_AMOUNT
                       END) DR_TOTAL,
                   SUM(CASE T_ACCOUNT_WATER.DR_CR_FLAG
                         WHEN 'CR' THEN
                          T_ACCOUNT_WATER.DR_CR_AMOUNT
                       END) CR_TOTAL

              FROM T_ACCOUNT_WATER
             WHERE T_ACCOUNT_WATER.STATUS = 'SUCCESS'
               AND T_ACCOUNT_WATER.ACCOUNT_DATE =
                   TO_CHAR(V_DAY_IDX, 'yyyyMMdd')

             GROUP BY T_ACCOUNT_WATER.PAYMENT_ORDER_NO,
                      T_ACCOUNT_WATER.ACCOUNT_NO
            HAVING SUM(CASE T_ACCOUNT_WATER.DR_CR_FLAG
              WHEN 'DR' THEN
               T_ACCOUNT_WATER.DR_CR_AMOUNT
            END) <> SUM(CASE T_ACCOUNT_WATER.DR_CR_FLAG
              WHEN 'CR' THEN
               T_ACCOUNT_WATER.DR_CR_AMOUNT
            END)) R
      LEFT JOIN MV_TRADE T
        ON R.PAYMENT_ORDER_NO = T.PAYMENT_ID;

  CURSOR CUR_ACC_BALANCE(V_DAY_IDX DATE) IS
    SELECT RET.ACCOUNT_NO,
           RET.SUBJECT_DR_CR,
           RET.CASH_AMOUNT,
           RET.FREEZE_AMOUNT,
           RET.OVERDRAFT_AMOUNT_LIMIT,
           RET.CUR_DR_AMOUNT,
           RET.CUR_CR_AMOUNT,
           RET.DR_AMOUNT,
           RET.CR_AMOUNT,
           Y_RET.YESTODAY_CASH_AMOUNT,
           Y_RET.YESTODAY_FREEZE_AMOUNT,
           Y_RET.YESTODAY_OVERDRAFT_AMOUNT,
           Y_RET.YESTODAY_DR_AMOUNT,
           Y_RET.YESTODAY_CR_AMOUNT
      FROM (SELECT T_ACCOUNT.ACCOUNT_NO,
                   T_ACCOUNT.SUBJECT_DR_CR,
                   T_ACCOUNT.CASH_AMOUNT,
                   T_ACCOUNT.FREEZE_AMOUNT,
                   T_ACCOUNT.OVERDRAFT_AMOUNT_LIMIT,
                   T_ACCOUNT.DR_AMOUNT              CUR_DR_AMOUNT,
                   T_ACCOUNT.CR_AMOUNT              CUR_CR_AMOUNT,
                   R.DR_AMOUNT,
                   R.CR_AMOUNT
              FROM T_ACCOUNT,
                   (SELECT SUM(CASE T_ACCOUNT_WATER.DR_CR_FLAG
                                 WHEN 'DR' THEN
                                  T_ACCOUNT_WATER.DR_CR_AMOUNT
                               END) DR_AMOUNT,
                           SUM(CASE T_ACCOUNT_WATER.DR_CR_FLAG
                                 WHEN 'CR' THEN
                                  T_ACCOUNT_WATER.DR_CR_AMOUNT
                               END) CR_AMOUNT,
                           T_ACCOUNT_WATER.ACCOUNT_NO
                      FROM T_ACCOUNT_WATER
                     WHERE T_ACCOUNT_WATER.ACCOUNT_DATE =
                           TO_CHAR(V_DAY_IDX, 'yyyyMMdd')

                       AND T_ACCOUNT_WATER.STATUS = 'SUCCESS'
                     GROUP BY T_ACCOUNT_WATER.ACCOUNT_NO) R
             WHERE T_ACCOUNT.ACCOUNT_NO = R.ACCOUNT_NO

            ) RET
      LEFT JOIN (SELECT T_ACCOUNT_DAILY.CASH_AMOUNT            YESTODAY_CASH_AMOUNT,
                        T_ACCOUNT_DAILY.FREEZE_AMOUNT          YESTODAY_FREEZE_AMOUNT,
                        T_ACCOUNT_DAILY.OVERDRAFT_AMOUNT_LIMIT YESTODAY_OVERDRAFT_AMOUNT,
                        T_ACCOUNT_DAILY.DR_AMOUNT              YESTODAY_DR_AMOUNT,
                        T_ACCOUNT_DAILY.CR_AMOUNT              YESTODAY_CR_AMOUNT,
                        T_ACCOUNT_DAILY.ACCOUNT_NO
                   FROM T_ACCOUNT_DAILY
                  WHERE T_ACCOUNT_DAILY.ACCOUNT_DATE =
                        TO_CHAR(V_DAY_IDX - 1, 'yyyyMMdd')) Y_RET
        ON RET.ACCOUNT_NO = Y_RET.ACCOUNT_NO;

BEGIN

  BEGIN
    --当前工作日
    SELECT TO_DATE(PARAM_VALUE, 'yyyyMMdd')
      INTO V_DAY_IDX
      FROM T_DAY_CHANGE
     WHERE T_DAY_CHANGE.PARAM_NAME = 'CUR_DAY';
    --同一支付流水记账借贷是否平衡
    OPEN CUR_ACC_DR_CR(V_DAY_IDX);
    --T.ORDER_ID, R.ACCOUNT_NO, R.PAYMENT_ORDER_NO, R.DR_TOTAL, R.CR_TOTAL
    FETCH CUR_ACC_DR_CR
      INTO V_ORDER_ID,
           V_ACCOUNT_NO,
           V_PAYMENT_ORDER_NO,
           V_DR_AMOUNT,
           V_CR_AMOUNT;

    WHILE CUR_ACC_DR_CR%FOUND LOOP
      ---订单是否需要冻结
      --  UPDATE T_RECHARGE TR SET TR.SETT_STATE ='FREEZEN' WHERE TR.ORDER_ID=V_ORDER_ID
      --将账户冻结
      UPDATE T_ACCOUNT
         SET T_ACCOUNT.ACCOUNT_STATE = 'FREEZE'
       WHERE T_ACCOUNT.ACCOUNT_NO = V_ACCOUNT_NO;
      --记录异常日志
      INSERT INTO T_ACCOUNT_LOG
        (ID, T_LOG_LEVEL, T_LOG_CONTENT, UPDATE_TIME)
      VALUES
        (SEQ_ACCOUNT_LOG.NEXTVAL,
         'ERROR',
         '账户(' || V_ACCOUNT_NO || ')支付流水号为:' || V_PAYMENT_ORDER_NO ||
         '借贷不平衡',
         CURRENT_TIMESTAMP);

      FETCH CUR_ACC_DR_CR
        INTO V_ORDER_ID,
             V_ACCOUNT_NO,
             V_PAYMENT_ORDER_NO,
             V_DR_AMOUNT,
             V_CR_AMOUNT;
    END LOOP;
    CLOSE CUR_ACC_DR_CR;
    ----- 账户当前余额=昨日余额+当日发生额
    OPEN CUR_ACC_BALANCE(V_DAY_IDX);

    FETCH CUR_ACC_BALANCE
      INTO V_ACCOUNT_NO,
           V_SUBJECT_DR_CR,
           V_CASH_AMOUNT,
           V_FREEZE_AMOUNT,
           V_OVERDRAFT_AMOUNT_LIMIT,
           V_CUR_DR_AMOUNT,
           V_CUR_CR_AMOUNT,
           V_DR_AMOUNT,
           V_CR_AMOUNT,
           V_YESTODAY_CASH_AMOUNT,
           V_YESTODAY_FREEZE_AMOUNT,
           V_YESTODAY_OVERDRAFT_AMOUNT,
           V_YESTODAY_DR_AMOUNT,
           V_YESTODAY_CR_AMOUNT;

    WHILE CUR_ACC_BALANCE%FOUND LOOP
      --数据错误则冻结账户
      IF V_YESTODAY_DR_AMOUNT > 0 AND V_YESTODAY_CR_AMOUNT = 0 THEN
        --余额在DR方
        V_TEMP_BALANCE := V_YESTODAY_DR_AMOUNT + V_DR_AMOUNT - V_CR_AMOUNT;
        V_ACCRUAL := V_DR_AMOUNT - V_CR_AMOUNT;

        IF V_TEMP_BALANCE > 0 THEN
          --余额在DR

          IF (V_CUR_CR_AMOUNT <> 0 OR V_CUR_DR_AMOUNT <> V_TEMP_BALANCE) THEN
            --调整账户余额 账户当前余额=昨日余额+当日发生额
            V_ADJUST := 1;
            V_ERRTEXT :=V_ACCOUNT_NO||'的DR余额应为:'||V_TEMP_BALANCE||',CR余额应为:0';
            CONTINUE;
          END IF;
        ELSIF V_TEMP_BALANCE < 0 THEN
          --余额在CR

          IF (V_CUR_DR_AMOUNT <> 0 OR
             V_CUR_CR_AMOUNT <> V_TEMP_BALANCE * -1) THEN
            --调整账户余额 账户当前余额=昨日余额+当日发生额
            V_ADJUST := 1;
           V_ERRTEXT :=V_ACCOUNT_NO||'的CR余额应为:'||V_TEMP_BALANCE * -1||',DR余额应为:0';
            CONTINUE;
          END IF;

        END IF;

      ELSIF V_YESTODAY_CR_AMOUNT > 0 AND V_YESTODAY_DR_AMOUNT = 0 THEN
        --昨日余额在CR方
        V_TEMP_BALANCE := V_YESTODAY_CR_AMOUNT + V_CR_AMOUNT - V_DR_AMOUNT;
         V_ACCRUAL := V_CR_AMOUNT -V_DR_AMOUNT;
        IF V_TEMP_BALANCE > 0 THEN
          --余额任在CR

          IF (V_CUR_DR_AMOUNT <> 0 OR V_CUR_CR_AMOUNT <> V_TEMP_BALANCE) THEN
            V_ADJUST := 1;
            V_ERRTEXT :=V_ACCOUNT_NO||'的CR余额应为:'||V_TEMP_BALANCE ||',DR余额应为:0';
             CONTINUE;
          END IF;
        ELSIF V_TEMP_BALANCE < 0 THEN
          --余额反向在DR
          IF (V_CUR_CR_AMOUNT <> 0 OR
             V_CUR_DR_AMOUNT <> V_TEMP_BALANCE * -1) THEN

            V_ADJUST := 1;
           V_ERRTEXT :=V_ACCOUNT_NO||'的DR余额应为:'||V_TEMP_BALANCE * -1 ||',CR余额应为:0';
            CONTINUE;
          END IF;

        END IF;

      ELSIF V_YESTODAY_CR_AMOUNT = 0 AND V_YESTODAY_DR_AMOUNT = 0 THEN
        --无昨日余额
        V_TEMP_BALANCE := V_CR_AMOUNT - V_DR_AMOUNT;
        V_ACCRUAL := V_CR_AMOUNT - V_DR_AMOUNT;
        IF V_TEMP_BALANCE > 0 THEN
          --余额任在CR

          IF (V_CUR_DR_AMOUNT <> 0 OR V_CUR_CR_AMOUNT <> V_TEMP_BALANCE) THEN
            V_ADJUST := 1;
            V_ERRTEXT :=V_ACCOUNT_NO||'的CR余额应为:'||V_TEMP_BALANCE  ||',DR余额应为:0';
            CONTINUE;
          END IF;
        ELSIF V_TEMP_BALANCE < 0 THEN
          --余额反向在DR
          IF (V_CUR_CR_AMOUNT <> 0 OR
             V_CUR_DR_AMOUNT <> V_TEMP_BALANCE * -1) THEN
            V_ADJUST := 1;
          V_ERRTEXT :=V_ACCOUNT_NO||'的DR余额应为:'||V_TEMP_BALANCE * -1  ||',CR余额应为:0';
           CONTINUE;
          END IF;

        END IF;

      END IF;
      IF (V_YESTODAY_CASH_AMOUNT +V_YESTODAY_FREEZE_AMOUNT+V_ACCRUAL <>V_CASH_AMOUNT + V_FREEZE_AMOUNT) THEN
          V_ADJUST := 1;
          V_ERRTEXT :=V_ACCOUNT_NO||'的余额错误,昨日余额为:'||(V_YESTODAY_CASH_AMOUNT +V_YESTODAY_FREEZE_AMOUNT) ||
          ',今日借方发生额:'||V_DR_AMOUNT||',贷方发生额'||V_CR_AMOUNT||',今日余额应为:'||(V_CASH_AMOUNT + V_FREEZE_AMOUNT);
          END IF;
      IF (V_ADJUST = 1) THEN
        UPDATE T_ACCOUNT
           SET T_ACCOUNT.ACCOUNT_STATE = 'FREEZE'
         WHERE T_ACCOUNT.ACCOUNT_NO = V_ACCOUNT_NO;
        --记录异常日志
        INSERT INTO T_ACCOUNT_LOG
          (ID, T_LOG_LEVEL, T_LOG_CONTENT, UPDATE_TIME)
        VALUES
          (SEQ_ACCOUNT_LOG.NEXTVAL,
           'ERROR',
           V_ERRTEXT,
           CURRENT_TIMESTAMP);
      END IF;
      FETCH CUR_ACC_BALANCE
        INTO V_ACCOUNT_NO,
             V_SUBJECT_DR_CR,
             V_CASH_AMOUNT,
             V_FREEZE_AMOUNT,
             V_OVERDRAFT_AMOUNT_LIMIT,
             V_CUR_DR_AMOUNT,
             V_CUR_CR_AMOUNT,
             V_DR_AMOUNT,
             V_CR_AMOUNT,
             V_YESTODAY_CASH_AMOUNT,
             V_YESTODAY_FREEZE_AMOUNT,
             V_YESTODAY_OVERDRAFT_AMOUNT,
             V_YESTODAY_DR_AMOUNT,
             V_YESTODAY_CR_AMOUNT;
    END LOOP;
    CLOSE CUR_ACC_BALANCE;

  EXCEPTION
    WHEN OTHERS THEN
      ROLLBACK WORK;
      RAISE_APPLICATION_ERROR(-20001, '日切出错出错!');
      RETURN;
  END;

END PROC_DAY_OVER_CALCULATE;




















CREATE OR REPLACE PROCEDURE PROC_ACCOUNT_DAILY AS

  V_DAY_IDX VARCHAR2(8);
  --V_COUNT   NUMBER;
  --V_SEQ_VAL NUMBER(15);

BEGIN

    /**、
    SELECT TO_DATE(PARAM_VALUE, 'yyyyMMdd')
    INTO V_DAY_IDX
    FROM T_DAY_CHANGE
   WHERE T_DAY_CHANGE.PARAM_NAME = 'CUR_DAY';
  SELECT COUNT(ID)
    INTO V_COUNT
    FROM T_ACCOUNT_DAILY
   WHERE T_ACCOUNT_DAILY.ACCOUNT_DATE = TO_CHAR(V_DAY_IDX, 'yyyyMMdd');
  IF V_COUNT > 0 THEN
    DELETE FROM T_ACCOUNT_DAILY
     WHERE T_ACCOUNT_DAILY.ACCOUNT_DATE = TO_CHAR(V_DAY_IDX, 'yyyyMMdd');
  END IF;
  */
  --更新日切时间
  --1、保留前日切时间
  --2、更新下一日切时间
   --记录异常日志
   INSERT INTO T_ACCOUNT_LOG (ID, T_LOG_LEVEL, T_LOG_CONTENT, UPDATE_TIME)
      VALUES (SEQ_ACCOUNT_LOG.NEXTVAL, 'INFO',
         '更新日切时间开始',
         CURRENT_TIMESTAMP);
 
  select t.param_value into V_DAY_IDX from t_day_change t where t.param_name='CUR_DAY';
  update t_day_change t
  set t.param_value = to_char(to_date(t.param_value, 'yyyyMMdd') + 1, 'yyyyMMdd'),
  t.update_time = sysdate;
 
  commit;
 
  INSERT INTO T_ACCOUNT_LOG (ID, T_LOG_LEVEL, T_LOG_CONTENT, UPDATE_TIME)
      VALUES (SEQ_ACCOUNT_LOG.NEXTVAL, 'INFO',
         '更新日切时间结束',
         CURRENT_TIMESTAMP);
 
 
  --账户日切表
  BEGIN
 
  INSERT INTO T_ACCOUNT_LOG (ID, T_LOG_LEVEL, T_LOG_CONTENT, UPDATE_TIME)
      VALUES (SEQ_ACCOUNT_LOG.NEXTVAL, 'INFO',
         '账户日切开始',
         CURRENT_TIMESTAMP);
 
    INSERT INTO T_ACCOUNT_DAILY
      (ID,
       ACCOUNT_DATE,
       ACCOUNT_TYPE,
       ACCOUNT_NO,
       ACCOUNT_NAME,
       SUBJECT_NO,
       SUBJECT_DR_CR,
       ACCOUNT_STATE,
       OVERDRAFT_FLAG,
       DR_AMOUNT,
       CR_AMOUNT,
       CASH_AMOUNT,
       FREEZE_AMOUNT,
       OVERDRAFT_AMOUNT_LIMIT,
       ALL_DR_AMOUNT,
       ALL_CR_AMOUNT,
       UPDATE_TIME)
      SELECT SEQ_ACCOUNT_DAILY.NEXTVAL,
             TO_CHAR(V_DAY_IDX, 'yyyyMMdd'),
             T_ACCOUNT.ACCOUNT_TYPE,
             T_ACCOUNT.ACCOUNT_NO,
             T_ACCOUNT.ACCOUNT_NAME,
             T_ACCOUNT.SUBJECT_NO,
             T_ACCOUNT.SUBJECT_DR_CR,
             T_ACCOUNT.ACCOUNT_STATE,
             T_ACCOUNT.OVERDRAFT_FLAG,
             T_ACCOUNT.DR_AMOUNT,
             T_ACCOUNT.CR_AMOUNT,
             T_ACCOUNT.CASH_AMOUNT,
             T_ACCOUNT.FREEZE_AMOUNT,
             T_ACCOUNT.OVERDRAFT_AMOUNT_LIMIT,
             NVL(A_STAT.DR_AMOUNT, 0),
             NVL(A_STAT.CR_AMOUNT, 0),
             CURRENT_TIMESTAMP
        FROM T_ACCOUNT
        LEFT JOIN (SELECT SUM(CASE T_ACCOUNT_WATER.DR_CR_FLAG
                                WHEN 'DR' THEN
                                 T_ACCOUNT_WATER.DR_CR_AMOUNT
                              END) DR_AMOUNT,
                          SUM(CASE T_ACCOUNT_WATER.DR_CR_FLAG
                                WHEN 'CR' THEN
                                 T_ACCOUNT_WATER.DR_CR_AMOUNT
                              END) CR_AMOUNT,
                          T_ACCOUNT_WATER.ACCOUNT_NO
                     FROM T_ACCOUNT_WATER
                    WHERE T_ACCOUNT_WATER.ACCOUNT_DATE =
                          TO_CHAR(V_DAY_IDX, 'yyyyMMdd')
                      AND T_ACCOUNT_WATER.STATUS = 'SUCCESS'
                    GROUP BY T_ACCOUNT_WATER.ACCOUNT_NO) A_STAT
          ON T_ACCOUNT.ACCOUNT_NO = A_STAT.ACCOUNT_NO;
    COMMIT;
   
    INSERT INTO T_ACCOUNT_LOG (ID, T_LOG_LEVEL, T_LOG_CONTENT, UPDATE_TIME)
      VALUES (SEQ_ACCOUNT_LOG.NEXTVAL, 'INFO',
         '账户日切结束',
         CURRENT_TIMESTAMP);
        
        
  EXCEPTION
    WHEN OTHERS THEN
      INSERT INTO T_ACCOUNT_LOG (ID, T_LOG_LEVEL, T_LOG_CONTENT, UPDATE_TIME)
      VALUES (SEQ_ACCOUNT_LOG.NEXTVAL,
       'ERROR',
         '账户日切异常',
         CURRENT_TIMESTAMP);
         commit;
  END;
  ----录入科目日均表
  BEGIN
  INSERT INTO T_ACCOUNT_LOG (ID, T_LOG_LEVEL, T_LOG_CONTENT, UPDATE_TIME)
      VALUES (SEQ_ACCOUNT_LOG.NEXTVAL,
       'INFO',
         '科目日报表统计开始',
         CURRENT_TIMESTAMP);
 
    INSERT INTO T_SUBJECT_DAY_BANLANCE_RPT
      (ID,
       SUBJECT_NO,
       SUBJECT_NAME,
       STA_DATE,
       DR_AMT,
       CR_AMT,
       TODAY_DR_BALANCE,
       TODAY_CR_BALANCE,
       PRE_DR_BALANCE,
       PRE_CR_BALANCE)
      SELECT SEQ_SUB_DAY_BALRPT.NEXTVAL,
             T_SUBJECT.SUBJECT_NO,
             T_SUBJECT.SUBJECT_NAME,
             V_DAY_IDX,
             NVL(RET.ALL_DR_AMOUNT, 0),
             NVL(RET.ALL_CR_AMOUNT, 0),
             NVL(RET.DR_AMOUNT, 0),
             NVL(RET.CR_AMOUNT, 0),
             NVL(RET.PRE_DR_AMOUNT, 0),
             NVL(RET.PRE_CR_AMOUNT, 0)
        FROM T_SUBJECT
        LEFT JOIN (SELECT CUR.*,
                          PRE.DR_AMOUNT PRE_DR_AMOUNT,
                          PRE.CR_AMOUNT PRE_CR_AMOUNT
                     FROM (SELECT T_ACCOUNT_DAILY.SUBJECT_NO,
                                  T_ACCOUNT_DAILY.ACCOUNT_DATE,
                                  SUM(T_ACCOUNT_DAILY.ALL_DR_AMOUNT) ALL_DR_AMOUNT,
                                  SUM(T_ACCOUNT_DAILY.ALL_CR_AMOUNT) ALL_CR_AMOUNT,
                                  SUM(T_ACCOUNT_DAILY.DR_AMOUNT) DR_AMOUNT,
                                  SUM(T_ACCOUNT_DAILY.CR_AMOUNT) CR_AMOUNT
                             FROM T_ACCOUNT_DAILY
                            WHERE T_ACCOUNT_DAILY.ACCOUNT_DATE =
                                  TO_CHAR(V_DAY_IDX, 'yyyyMMdd')
                            GROUP BY T_ACCOUNT_DAILY.ACCOUNT_DATE,
                                     T_ACCOUNT_DAILY.SUBJECT_NO) CUR
                     LEFT JOIN (SELECT T_ACCOUNT_DAILY.SUBJECT_NO,
                                      T_ACCOUNT_DAILY.ACCOUNT_DATE,
                                      SUM(T_ACCOUNT_DAILY.DR_AMOUNT) DR_AMOUNT,
                                      SUM(T_ACCOUNT_DAILY.CR_AMOUNT) CR_AMOUNT
                                 FROM T_ACCOUNT_DAILY
                                WHERE T_ACCOUNT_DAILY.ACCOUNT_DATE =
                                      TO_CHAR(V_DAY_IDX - 1, 'yyyyMMdd')
                                GROUP BY T_ACCOUNT_DAILY.ACCOUNT_DATE,
                                         T_ACCOUNT_DAILY.SUBJECT_NO) PRE
                       ON CUR.SUBJECT_NO = PRE.SUBJECT_NO
                      AND CUR.ACCOUNT_DATE = PRE.ACCOUNT_DATE) RET
          ON T_SUBJECT.SUBJECT_NO = RET.SUBJECT_NO;
         
          commit;
         
          INSERT INTO T_ACCOUNT_LOG (ID, T_LOG_LEVEL, T_LOG_CONTENT, UPDATE_TIME)
      VALUES (SEQ_ACCOUNT_LOG.NEXTVAL,
       'INFO',
         '科目日报表统计结束',
         CURRENT_TIMESTAMP);
        
  EXCEPTION
    WHEN OTHERS THEN
      INSERT INTO T_ACCOUNT_LOG (ID, T_LOG_LEVEL, T_LOG_CONTENT, UPDATE_TIME)
      VALUES (SEQ_ACCOUNT_LOG.NEXTVAL,
       'ERROR',
         '',
         CURRENT_TIMESTAMP);
         commit;
  END;

END PROC_ACCOUNT_DAILY;











CREATE OR REPLACE VIEW MV_TRADE AS
SELECT
  T .ORDER_ID,
  T .AMOUNT,
  T .SUBJECT,
  T .TRADE_CATEGORY,
  T .TRADE_TYPE,
  T .STATUS,
  T .BUYER_ID,
  T .BUYER_LOGIN_ID,
  T .BUYER_NAME,
  T .SELLER_ID,
  T .SELLER_LOGIN_ID,
  T .SELLER_NAME,
  T .PAYMENT_ID,
  T .CREATE_DATE,
  T .UPDATE_USER
FROM
  T_RECHARGE T
UNION
  SELECT
    T .ORDER_ID,
    T .AMOUNT,
    T .SUBJECT,
    T .TRADE_CATEGORY,
    T .TRADE_TYPE,
    T .STATUS,
    T .BUYER_ID,
    T .BUYER_LOGIN_ID,
    T .BUYER_NAME,
    T .SELLER_ID,
    T .SELLER_LOGIN_ID,
    T .SELLER_NAME,
    T .PAYMENT_ID,
    T .CREATE_DATE,
    T .UPDATE_USER
  FROM
    T_TRADE_ORDER T
  UNION
    SELECT
      T .ORDER_ID,
      T .AMOUNT,
      T .SUBJECT,
      T .TRADE_CATEGORY,
      T .TRADE_TYPE,
      T .STATUS,
      T .BUYER_ID,
      T .BUYER_LOGIN_ID,
      T .BUYER_NAME,
      T .SELLER_ID,
      T .SELLER_LOGIN_ID,
      T .SELLER_NAME,
      T .PAYMENT_ID,
      T .CREATE_DATE,
      T .UPDATE_USER
    FROM
      T_WITHDRAW T;









分享到:
评论

相关推荐

    Oracle 9i Client (Oracle 9i 客户端) 简化版 (不安装Oracle客户端,也可以使用PLSQL Developer)

    Oracle 9i Client (Oracle 9i 客户端) 简化版 (不安装Oracle客户端,也可以使用PLSQL Developer 不用安装Oracle客户端也可以使用PLSQL Developer 绿色! 安全! 轻便! 可靠! 1、本软件可作为简单的Oracle9i客户端...

    oracle10G和oracle11G的OCI.dll

    oci.dll是Oracle Call Interface的缩写,它是Oracle数据库的一个核心组件,允许开发者使用各种编程语言与Oracle数据库进行交互。在Oracle 10G和11G版本中,oci.dll扮演了至关重要的角色,为应用程序提供了访问数据库...

    oracle.jdbc.driver.oracledriver Oracle JDBC驱动包 ojdbc6

    Oracle JDBC驱动包是Oracle数据库与Java应用程序之间进行通信的关键组件,它使得Java程序员能够通过编写Java代码来操作Oracle数据库。标题中的"ojdbc6"指的是Oracle JDBC驱动的一个特定版本,适用于Java SE 6环境。...

    cx_Oracle使用手册

    cx_Oracle是Python编程语言中用于连接Oracle数据库的一个模块。该模块遵循Python数据库API规范,并且适用于Oracle 11.2和12.1版本,同时兼容Python 2.x和3.x版本。cx_Oracle模块通过使用Oracle客户端库来实现与...

    基于C#连接Oracle数据库Oracle.ManagedDataAccess

    首先,Oracle.ManagedDataAccess是Oracle公司提供的一个纯.NET框架的客户端驱动,它允许开发者在不安装Oracle客户端的情况下,直接与Oracle数据库进行交互。这个库包含了所有必要的组件,使得C#程序可以方便地执行...

    Python连接oracle工具cx_Oracle官方文档

    cx_Oracle是Python数据库API规范的实现,用于访问Oracle数据库。目前,该模块经过对Oracle客户端版本11.2、12.1和12.2以及Python版本2.7、3.4、3.5和3.6的测试。cx_Oracle遵循开源的BSD许可证,这表示用户可以自由地...

    OracleClient-19C Oracle客户端,包括windows和Linux

    Oracle Client是Oracle公司提供的数据库连接工具,用于与Oracle数据库服务器进行通信。19C是Oracle Database的一个版本,代表第19个主要版本。这个压缩包包含的Oracle Client适用于Windows和Linux操作系统,使得...

    《Oracle 12c数据库基础教程》教学课件—03Oracle数据库管理工具.pdf

    《Oracle 12c数据库基础教程》教学课件—03Oracle数据库管理工具.pdf《Oracle 12c数据库基础教程》教学课件—03Oracle数据库管理工具.pdf《Oracle 12c数据库基础教程》教学课件—03Oracle数据库管理工具.pdf《Oracle...

    Mysql转Oracle软件 DBMover for Mysql to Oracle

    Dbmover for Mysql to Oracle 是高效的将Mysql导入到Oracle数据库的工具。 使用DBMover可以灵活定义Mysql和Oracle之间表和字段的对照关系,也可以在DBMover创建一个查询,把查询结果当作源表转入到Oracle中。 ...

    Oracle11g客户端精简版

    Oracle 11g客户端是Oracle数据库的一个轻量级版本,主要供开发人员和系统管理员用于连接到Oracle数据库服务器,执行查询、管理和维护数据库任务。这个精简版在保持基本功能的同时,减少了安装体积,便于快速部署和...

    Oracle Ojdbc各版本驱动包

    Oracle各版本驱动包,有需要的可以下载使用,支持目前常用的不同版本oracle和JDK,根据自己需要调整和使用 主要包括的jar有: ojdbc5.jar 适用JDK版本:JDK 1.5 对应Oracle数据库版本:Oracle数据库版本(如Oracle ...

    Tianlesoftware Oracle 学习手册(v1.0)高清完整PDF版

    ### Tianlesoftware Oracle 学习手册(v1.0)中的关键知识点 #### 1. ORACLE基础知识 ##### 1.1 OLAP与OLTP介绍 **1.1.1 什么是OLTP** OLTP(Online Transaction Processing,在线事务处理)是一种主要针对企业...

    利用python-oracledb库连接Oracledb数据库,使用示例

    python-oracledb的源码和使用示例代码, python-oracledb 1.0,适用于Python versions 3.6 through 3.10. Oracle Database; This directory contains samples for python-oracledb. 1. The schemas and SQL ...

    Oracle19c-Windows客户端

    Oracle 19c是Oracle数据库的一个重要版本,尤其在Windows平台上,它提供了全面的功能和优化,使得数据库管理和开发更为高效。以下将详细讲解Oracle 19c Windows客户端的关键知识点: 1. **Oracle Client**: Oracle...

    Veeam 备份恢复oracle数据库详细配置文档

    Veeam 备份恢复 Oracle 数据库详细配置文档 本文档旨在详细介绍如何使用 Veeam 备份恢复 Oracle 数据库的配置过程。该文档将指导读者从环境准备到推送 Oracle RMAN Plugin,再到创建备份作业和运行备份作业,最后...

    oracle经典书籍(Oracle 9i初学者指南.zip、Oracle专家高级编程.pdf、Effective+Oracle+by+Design.pdf)

    这里提到的三本书籍——"Oracle 9i初学者指南.zip"、"Oracle专家高级编程.pdf"以及"Effective Oracle by Design.pdf"都是Oracle学习者和专业开发者的宝贵资源。 "Oracle 9i初学者指南.zip":这是一本针对Oracle 9i...

    Oracle Instant Client 11.2.0.1.0 轻量级Oracle客户端

    Oracle Instant Client 11.2.0.1.0是轻量级Oracle客户端,用于连接访问Oracle 9i、10g、11g 11.2.0.1.0版本的Oracle数据库。 Oracle Instant Client11.2.0.1.0 安装程序包含OCI/ OCCI、JDBC-OCI SDK(软件开发工具...

    oracle 客户端 64位

    Oracle客户端是用于与Oracle数据库服务器交互的软件工具,主要功能是提供对数据库的查询、更新、管理等操作。Oracle客户端支持多种操作系统,包括Windows,且有32位和64位之分。在这个场景中,我们关注的是"Oracle...

    解决System.Data.OracleClient 需要 Oracle 客户端软件 8.1.7 或更高版本

    标题中的“System.Data.OracleClient 需要 Oracle 客户端软件 8.1.7 或更高版本”是一个常见的错误提示,它涉及到在.NET环境中使用Oracle数据库时遇到的问题。这个错误表明,当你试图在应用程序中使用System.Data....

    无需安装oracle客户端直接连接使用oracle数据库的解决方案

    本人琢磨了下使用VS .Net 2005开发的客户端程序,需要访问oracle数据库,但不想在客户端安装oracle客户端的解决方法。终于给弄清楚了,其实根本不需要在安装oracle客户端就可以轻松实现了。方法是将相关的9个oracle...

Global site tag (gtag.js) - Google Analytics