aonestar
.public
Tables
(current)
Columns
Constraints
Relationships
Orphan Tables
Anomalies
Routines
sp_trg_department_before_delete
Parameters
Name
Type
Mode
Definition
begin -- === create by T.Supol 2025-06-26 -- Modified by Pisanu 2025-07-06 IF old.id::text = any(fn_get_params('DEPOSIT', '{DEFAULT_PAYMENT_ID,NOSHOW_DEPT_ID,CANCEL_DEPT_ID,REFUND_PAYMENT_ID}')) THEN raise exception 'Cannot delete, % is being used as system parameters.', old.name; END IF; IF old.id::text = any(fn_get_params('AUTO_POST', '{ROOM,ABF,LUNCH,DINNER}')) THEN raise exception 'Cannot delete, % is being used as system parameters.', old.name; END IF; IF exists(select 1 from transactions t where t.dept_id = old.id) THEN raise exception 'Cannot delete, % is being used in some transactions.', old.name; END IF; -- error_msg := format('Cannot delete, %s is being used as system parameters.', old.name); -- -- if fn_sys_param('DEPOSIT','DEFAULT_PAYMENT_ID',null::int4) = old.id then -- raise exception using message = error_msg; -- end if; -- -- if fn_sys_param('DEPOSIT','NOSHOW_DEPT_ID',null::int4) = old.id then -- raise exception using message = error_msg; -- end if; -- -- if fn_sys_param('DEPOSIT','CANCEL_DEPT_ID',null::int4) = old.id then -- raise exception using message = error_msg; -- end if; -- -- if fn_sys_param('DEPOSIT','REFUND_PAYMENT_ID',null::int4) = old.id then -- raise exception using message = error_msg; -- end if; -- -- if fn_sys_param('AUTO_POST','ROOM',null::int4) = old.id then -- raise exception using message = error_msg; -- end if; -- -- if fn_sys_param('AUTO_POST','ABF',null::int4) = old.id then -- raise exception using message = error_msg; -- end if; -- -- if fn_sys_param('AUTO_POST','LUNCH',null::int4) = old.id then -- raise exception using message = error_msg; -- end if; -- -- if fn_sys_param('AUTO_POST','DINNER',null::int4) = old.id then -- raise exception using message = error_msg; -- end if; return old; END;