【问题标题】:how to avoid a transaction for the employee if more than one transaction is approved on same day?如果同一天批准了多笔交易,如何避免员工进行交易?
【发布时间】:2015-12-08 13:23:05
【问题描述】:

如果同一天批准了多笔交易,如何避免员工的交易? 请尽快帮助我。

【问题讨论】:

  • 有一个唯一的约束?

标签: sql plsql


【解决方案1】:
-- To check in the anonymous block code if CONSTRAINT cannot be applied later on the table

    DECLARE
      lv_cnt PLS_INTEGER;
      lv_emp PLS_INTEGER;
      lv_day DATE;
    BEGIN
      SELECT COUNT(1)
      INTO lv_cnt
      FROM emp
      WHERE empno          = lv_emp
      AND transaction_stat = 'APPROVED'
      AND tran_date        = lv_day;
      IF lv_cnt            > 1 THEN
        RAISE_APPLICATION_ERROR(-200001,'Cannot proceed with this transaction as already approved transaction for this day is present',TRUE);
      ELSE
        dbms_output.put_line('your piece of code for new transaction');
      END IF;
    END;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-08-15
    • 2018-09-12
    • 2022-10-25
    • 1970-01-01
    • 2020-10-20
    • 2019-07-16
    • 2021-10-25
    • 1970-01-01
    相关资源
    最近更新 更多