Monday, March 7, 2011

Oracle Form Session

==================================================
Oracle form session (Oracle E-Business Suite Form Session) Query

==================================================

SELECT   p.spid,
         s.process,
         s.status,
         s.machine,
         TO_CHAR (s.logon_time, 'mm-dd-yy hh24:mi:ss') Logon_Time,
         s.last_call_et / 3600 Last_Call_ET,
         s.action,
         s.module,
         s.sid,
         s.serial#,
         s.osuser,
         SUBSTR (REPLACE (s.action, 'FRM:', ''),
                 1,
                 INSTR (REPLACE (s.action, 'FRM:', ''), ':') - 1)
            user_name
  FROM   V$SESSION s, V$PROCESS p
 WHERE       s.paddr = p.addr
         AND s.username IS NOT NULL
         AND s.username = 'APPS'
         AND s.action LIKE 'FRM%' 



============================================================
How to kill inactive oracle form session (Oracle E-Business Suite Form Session)============================================================

DECLARE

   CURSOR CUR_INACTIVE_SESSION
   IS
        SELECT   p.spid,
                 s.process,
                 s.status,
                 s.machine,
                 TO_CHAR (s.logon_time, 'mm-dd-yy hh24:mi:ss') Logon_Time,
                 s.last_call_et / 3600 Last_Call_ET,
                 s.action,
                 s.module,
                 s.sid,
                 s.serial#,
                 s.osuser,
                    'alter system kill session '''
                 || s.sid
                 || ','
                 || s.serial#
                 || ''''
                    sql_string
          FROM   V$SESSION s, V$PROCESS p
         WHERE       s.paddr = p.addr
                 AND s.username IS NOT NULL
                 AND s.username = 'APPS'
                 AND UPPER (s.osuser) = 'APPCBSP'
                 AND s.last_call_et / 3600 > 8        /*   (Inactive sessions running for more than 8 hrs) */

                 AND s.action LIKE 'FRM%'
                 AND s.status = 'INACTIVE'
      ORDER BY   p.spid;


BEGIN
   FOR REC1 IN CUR_INACTIVE_SESSION
   LOOP

      BEGIN
         EXECUTE IMMEDIATE REC1.sql_string;
      EXCEPTION
         WHEN OTHERS
         THEN
            DBMS_OUTPUT.put_line (SQLERRM);

      END;
   END LOOP;
END;

Visit for more information http://blog.optiosys.com/

No comments:

Post a Comment