*==================================================
** PROCEDURE: check_effcitive_utl
Description:
唯一性规则:同一事项、公司、部门
不允许有两条及以上有效记录(有效范围不允许交叉)。
若违反唯一性规则,则在保存的时候报错:同一有效期内已存在相同记录行。
**==================================================*/
PROCEDURE check_effcitive IS
ln_count NUMBER;
BEGIN
ln_count := 0;
SELECT COUNT(1)
INTO ln_count
FROM cux_eco_parameter xep
WHERE 1 = 1
AND (:header.eco_parameter_id IS NULL OR xep.eco_parameter_id <> :header.eco_parameter_id)--主键
AND xep.matter_code = :header.matter_code
AND (xep.org_id = :header.org_id or (xep.org_id is null AND :header.org_id is null))
AND (xep.department_code = :header.department_code or (xep.department_code is null and :header.department_code is null))
AND ((xep.enable_flag ='Y' AND :header.enable_flag ='Y') or (xep.enable_flag is null AND :header.enable_flag is null))
AND :header.start_date <= nvl(xep.end_date,
:header.start_date)
AND (:header.end_date IS NULL OR :header.end_date >= xep.start_date);
IF ln_count > 0 THEN
fnd_message.set_name('CUX',
'CUX_ECO_EFFECTIVE_MESSAGE');
fnd_message.error;
RAISE form_trigger_failure;
END IF;
END check_effcitive;
需要添加触发器:
WHEN-VALIDATE-RECORD
ON-INSERT
ON-UPDATE