zoukankan      html  css  js  c++  java
  • How to Log Users Login and Logout Details Through Oracle Forms

    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.
     
    Track user login logout activity in Oracle Forms
    In this example one table and a sequence object is used to log the data in to table called login_out and the login information would be logged through Post-Logon trigger and logout information would be logged through Pre-Logout trigger in Oracle 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 (10) PRIMARY KEY,
       loguser   VARCHAR2 (20 BYTE),
       indate    DATE,
       outdate   DATE
    )
    /

    3. Create a Post-Logon Trigger at Form Level in Main Form of Your Application.

    DECLARE
       v_seq    NUMBER (10);
       v_user   VARCHAR2 (20) := GET_APPLICATION_PROPERTY (username);
    BEGIN
     
       SELECT login_seq.NEXTVAL INTO v_seq FROM DUAL;
      
       /* this global variable is created to use on pre-logout trigger to update the correspondent record. */
       :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 Form Level in Main Form of Your Application.

    DECLARE
       v_seq    NUMBER (10) := :GLOBAL.login_seq;
    BEGIN
     
       Update login_out
          set outdate = SYSDATE
          where srlno = v_seq;
     
    -- No need to commit here it will do automatically
     
    EXCEPTION
       WHEN OTHERS
       THEN
          RAISE form_trigger_failure;
    END;

    Now run the form and after that 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 of your application, not in every form.

  • 相关阅读:
    [原创]桓泽学音频编解码(13):AC3 位分配模块算法分析
    白话红黑树系列之一——初识红黑树
    白话红黑树系列之二——红黑树的构建
    数据驱动编程之表驱动法
    每周一算法之六——KMP字符串匹配算法
    HDOJ 1098 Ignatius's puzzle
    HDOJ 1097 A hard puzzle(循环问题)
    HDOJ 1019 Least Common Multiple(最小公倍数问题)
    辗转相除法_欧几里得算法_java的实现(求最大公约数)
    HDOJ 1020 Encoding
  • 原文地址:https://www.cnblogs.com/quanweiru/p/6218878.html
Copyright © 2011-2022 走看看