ITPub博客

首页 > Linux操作系统 > Linux操作系统 > Logon DB Trigger to Setup the User Environment[akadia]

Logon DB Trigger to Setup the User Environment[akadia]

原创 Linux操作系统 作者:jlandzpa 时间:2019-04-15 22:36:05 0 删除 编辑

Date and time format settings are based on the user's locale and native language. For example, SCOTT needs default NLS_DATE_FORMAT "MM/DD/YYYY", and ZAHN needs default "DD-MON-YYYY".,etc. The idea is to create an AFTER LOGON trigger at database level, which reads LOGON session UserName and sets up NLS_DATE_FORMAT by executing ALTER SESSION dynamically.

CREATE OR REPLACE TRIGGER setup_env
AFTER LOGON
ON DATABASE
declare
c integer;
r integer;
BEGIN
IF SYS_CONTEXT('userenv','session_user') = 'SCOTT' THEN
c := dbms_sql.open_cursor();
dbms_sql.parse(c,'alter session set nls_date_format='||
chr(39)||'MM/DD/YYYY'||chr(39), dbms_sql.NATIVE);
r:=dbms_sql.execute(c);
dbms_sql.close_cursor(c);
ELSIF SYS_CONTEXT('userenv','session_user') = 'ZAHN' THEN
c := dbms_sql.open_cursor();
dbms_sql.parse(c,'alter session set nls_date_format='||
chr(39)||'DD-MON-YYYY'||chr(39), dbms_sql.NATIVE);
r:=dbms_sql.execute(c);
dbms_sql.close_cursor(c);
END IF;
END;
/


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/936/viewspace-60597/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2001-10-12

  • 博文量
    240
  • 访问量
    172285