周浩

  BlogJava :: 首页 :: 新随笔 :: 联系 ::  :: 管理 ::
  28 随笔 :: 0 文章 :: 16 评论 :: 0 Trackbacks
CREATE OR REPLACE TRIGGER tr_login_record
AFTER logon ON DATABASE
DECLARE
miUserSid NUMBER;
mtSession v$session%ROWTYPE;
CURSOR cSession(iiUserSid IN NUMBER) IS
SELECT * FROM v$session WHERE sid = iiUserSid;
BEGIN
SELECT sid INTO miUserSid FROM v$mystat WHERE rownum <= 1;
OPEN cSession(miUserSid);
FETCH cSession
INTO mtSession;
--if user exists then insert data
IF cSession%FOUND THEN
insert into login$information
(login_user,
login_time,
ip_adress,
ausid,
terminal,
osuser,
machine,
program,
sid,
serial#)
VALUES
(ora_login_user,
SYSDATE,
SYS_CONTEXT('USERENV', 'IP_ADDRESS'),
userenv('SESSIONID'),
mtSession.Terminal,
mtSession.Osuser,
mtSession.Machine,
mtSession.Program,
mtSession.Sid,
mtSession.Serial#);
ELSE
null;
CLOSE cSession;
raise_application_error(-20099, 'Login Exception', FALSE);
END IF;
CLOSE cSession;
EXCEPTION
WHEN OTHERS THEN
null;
END tr_login_record;
posted on 2006-05-25 11:21 Derek 阅读(307) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航:
 
Google