I want to grant TRIGGERS, FUNCTIONS and PROCEDURES to a role. I have the code to do it with procedure but with triggers and functions it not work.
create role Level1;
grant execute any trigger to Level1;
grant execute any procedure to Level1;
>Solution :
User owns tables, functions and procedures. That user created a role and wanted to grant execute on various objects to the role.
-
for triggers, it doesn’t make sense – they fire upon certain action on the table they are created on. Therefore, you’d grant privileges on the table, not on the trigger
-
for functions and procedures, you’d grant execute privilege on exact functions and procedures (not for all of them in a single statement), e.g.
grant execute on p_insert_student to level1; grant execute on f_average_marks to level1;
What you posted (grant execute any procedure) is a system privilege; that’s kind of dangerous; are you sure you want to let level1 execute absolutely any procedure within the database?
Also, there’s no separate grant for functions; in this context, they are considered to be procedures so execute any procedure affects functions as well.