Log user ' s login and logout details in to table through Oracle Forms
using Post-logon and pre-logout triggers To track the user's login and logout activity for auditing purposes. In this example one table and a sequence object are used to logs the data in to table called Login_out and the login Informa tion would be logged through Post-logon trigger and logout information would being logged through Pre-logout trigger in Oracl E Forms. Follow the below mentioned steps to perform this task. 1. Create a Sequence object in Oracle Database. CREATE SEQUENCE login_seq START with 1 INCREMENT by 1 NOCACHE
/2. Create a Table in Oracle Database. CREATE TABLE Login_out (srlno number (Ten) PRIMARY KEY, LogUser VARCHAR2 (BYTE), Indate DATE, Outd Ate DATE)
/3. Create a Post-logon Trigger at the form level in Main form of Your application. DECLARE v_seq Number (10); v_user VARCHAR2: = Get_application_property (username); BEGIN SELECT login_seq. Nextval to V_seq from DUAL; /* This global variable are created to use on Pre-logout trigger to update the correspondent Reco Rd. */ : Global.login_seq: = V_seq; INSERT into Login_out (Srlno, LogUser, indate) VALUES (v_ Seq, V_user, sysdate); COMMIT; EXCEPTION when OTHERS then RAISE form_trigger_ Failure END; 4. Create a pre-logout Trigger at the form level in Main form of Your application. DECLARE v_seq Number (Ten): =: global.login_seq; BEGIN Update login_out Set outdate = Sysdate where srlno = V_seq; --No need to commits here it'll do automatically EXCEPTION when OTHERS then &nbs p; RAISE form_trigger_failure; END;
Now run the form and after so you can check the Login_out table to view the data as following:
SELECT * from Login_out WHERE TRUNC (indate) = TRUNC (sysdate)/
Note:these triggers should added into Main form only the your application, not in every form.
How to Log Users Login and Logout Details Through Oracle Forms