Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PROCEDURE checkPersonAccessRights2(p_vehicle_owner_id IN NUMBER, p_person_id IN NUMBER) IS
- -- POST : users with access on p_vehicle_owner_id and preferences like '%checkinAtWork%' will have a right on p_person_id (a record in gu_person)
- -- right is with CAW_only null if the person has a right on p_person_id vehicle owner
- -- right is with CAW_only ='Y' in other cases
- -- if right already exist, lm_date is updated
- -- list gui_users with access on p_vehicle_owner_id
- CURSOR c_gu IS
- SELECT DISTINCT gu.gui_user_id
- FROM gui_users gu, gu_vehicle_owner guvo
- WHERE guvo.vehicle_owner_id=p_vehicle_owner_id
- AND gu.gui_user_id = guvo.gui_user_id
- AND gu.preferences LIKE '%checkinAtWork%'
- AND ( (gu.user_admin_right IN ('SO','FM','VAR'))
- OR ( (guvo.vo_vehicle_category_id IS NULL) AND (guvo.vo_person_category_id IS NULL) AND (guvo.vo_group_id IS NULL) )
- );
- v_current_date DATE;
- v_gu_person_id NUMBER(10);
- v_nbr_access NUMBER(10); -- already existing rights for the hui_user on the person
- v_nbr_vo_access NUMBER(10); -- nbr rights on the person VO in gu_vehicle_owner.
- v_caw_limited CHAR(1);
- BEGIN
- v_current_date := SYSDATE;
- FOR r_gu IN c_gu
- LOOP
- SELECT COUNT(*)
- INTO v_nbr_access
- FROM gu_person gup
- WHERE gup.person_id= p_person_id
- AND gup.gui_user_id = r_gu.gui_user_id;
- IF v_nbr_access > 0
- THEN
- -- right on p_person_id already exist, update lm_date
- UPDATE gu_person gup
- SET lm_date = v_current_date
- WHERE gup.person_id= p_person_id
- AND gup.gui_user_id = r_gu.gui_user_id;
- ELSE
- -- check if gui_user has access to p_person_id vehicle owner
- SELECT COUNT(*)
- INTO v_nbr_vo_access
- FROM gu_vehicle_owner guvo, person p, vo_person_category vopc
- WHERE guvo.gui_user_id = r_gu.gui_user_id
- AND guvo.vehicle_owner_id = vopc.vehicle_owner_id
- AND vopc.vo_person_category_id = p.vo_person_category_id
- AND p.person_id = p_person_id;
- IF v_nbr_vo_access > 0
- THEN
- v_caw_limited :=NULL;
- ELSE
- v_caw_limited :='Y';
- END IF;
- INSERT INTO gu_person (gui_user_id, person_id, caw_limited, creation_date, lm_date)
- VALUES (r_gu.gui_user_id, p_person_id, v_caw_limited, v_current_date,v_current_date);
- END IF;
- END LOOP; -- c_gup
- EXCEPTION WHEN OTHERS THEN
- NULL;
- END;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement