G-7710
🆓Warning
Avoid cascading triggers.
Reason
Having triggers that act on other tables in a way that causes triggers on that table to fire lead to obscure behavior.
Example
Non-Compliant Example
create or replace trigger dept_br_u
before update on departments for each row
begin
insert into departments_hist (
department_id
,department_name
,manager_id
,location_id
,modification_date)
values (
:old.department_id
,:old.department_name
,:old.manager_id
,:old.location_id
,sysdate);
end;
/
create or replace trigger dept_hist_br_i
before insert on departments_hist for each row
begin
insert into departments_log (
department_id
,department_name
,modification_date)
values (
:new.department_id
,:new.department_name
,sysdate);
end;
/Issues
| Line | Column | Message |
|---|---|---|
| 4 | 16 |
Compliant Solution - ★★★★★
create or replace trigger dept_br_u
before update on departments for each row
begin
insert into departments_hist (
department_id
,department_name
,manager_id
,location_id
,modification_date)
values (
:old.department_id
,:old.department_name
,:old.manager_id
,:old.location_id
,sysdate);
insert into departments_log (
department_id
,department_name
,modification_date)
values (
:old.department_id
,:old.department_name
,sysdate);
end;
/Parameters
Use parameters to customize the rule to your needs.
| Parameter | Description | Default Value |
|---|---|---|
| SchemaNames | Comma-separated list of database schemas owning the database objects of an application. | dbl_owner |
References
- same as Trivadis G-7710