【发布时间】:2015-12-08 13:23:05
【问题描述】:
如果同一天批准了多笔交易,如何避免员工的交易? 请尽快帮助我。
【问题讨论】:
-
有一个唯一的约束?
如果同一天批准了多笔交易,如何避免员工的交易? 请尽快帮助我。
【问题讨论】:
-- 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;
【讨论】: