SQL: VS report triggers for each row

EDIT: I don't know what kind of distribution this is, this is in an exam article.

I just don't get it, unfortunately. I am quite happy with the Row level triggers, but can someone explain to me how the results would differ if the trigger was an instruction level instead?

Relationship / Arming / Row Level Trigger

Employee(ID VARCHAR2(30), Salary NUMBER) Create Trigger AutoRaise After insert on Employee Referencing new table as NT update Employee Set salary = salary + (select avg(salary) from NT) Create trigger AutoRaise After insert on Employee Referencing new table as NT For each Row Update employee Set salary = salary + (select avg(salary) from NT) 

I understand that in every line trigger it will fire for every line affected by the launch statement. Now the instruction level trigger will change the results differently? Say, if I inserted five tuples in one statement, I would set a salary, etc. For all? If so, what effect is triggered at the row level?

I tried searching, but I just can't get around it.

Thanks,

EDIT: Now, I'm just tight, but will it either run different results? For an instruction level trigger, if I used example values:

In the table before creating the trigger:

 (A,50) 

An operator has been added to the ONE after the trigger fires:

 (B,70), (C,30) 

The first trigger would set a salary for each inserted set, right? Thus, the first value will be 120 (the average value is 50, 70 + 50 = 120), and the second will be 80. If so, then how does the second trigger differ in results?

+7
source share
1 answer

The difference is that in the case of a trigger at the instruction level, the trigger will return the average salary for the inserted rows, but in the case of the row level, avg(salary) always equal to the salary new record (trigger executed individually for each row). In addition, a runlevel trigger will be executed if no entries are affected. In the case of a level trigger, most RDMS do not fire it if 0 records are affected.

Side note. I believe that trigger bodies in a question are given, for example, only; otherwise, I would recommend not using recursion in triggers, even if a particular RDMS has this option.

+4
source

All Articles