I should mention when you select from a table within the trigger that is firing on that table you will get a mutating table error. By moving the code to a procedure and creating an autonomous transaction you remove this limitation because the transaction firing the trigger is allowed to end and the transaction querying the data can run without effecting the primary transaction. There is a lot of information out there concerning mutating tables and triggers. Specifically what you can and can't do in a trigger.