Answer the question
In order to leave comments, you need to log in
How to make a trigger fire when a certain role enters?
Good day! I am doing an Oracle database administration task, the teacher said to create several roles (Storeman, Admin and customer)
create role kladovshchik;
create role zakazchik;
create role admin_role;
CREATE OR REPLACE TRIGGER vhod_tolko_po_budnjam AFTER LOGON ON DATABASE DECLARE
current_day NUMBER;
user_role NUMBER;
BEGIN
SELECT DISTINCT
COUNT(*)
INTO user_role
FROM
user_role_privs
WHERE
granted_role = 'admin_role'; --Проверяем роль
SELECT
to_char(sysdate, 'D')
INTO current_day
FROM
dual; --получаем день недели
IF
( current_day > 5 )
AND ( user_role >= 1 )
THEN --если вошел после пятницы и роль админ
raise_application_error(-20000, 'Приходите в будни!');
END IF;
END;
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question