create or replace trigger login
after LOGON ON DATABASE
begin
if to_char(sysdate,'dy')in ('sat','san') then
raise_application_error(-20123,' we cant logon the database ');
end if;
end;
CREATE OR REPLACE TRIGGER login_trg
AFTER LOGON ON DATABASE
DECLARE
BEGIN
IF to_char(SYSDATE,'D') NOT IN ('6','7') THEN
raise_application_error(-20123,' we cant logon the database ');
END IF;
END;
SQL> ALTER SESSION SET NLS_DATE_LANGUAGE = 'ENGLISH';
Session altered.
SQL> SELECT TO_CHAR(SYSDATE, 'dy') FROM DUAL;
TO_CHAR(SYSD
------------
tue
SQL> ALTER SESSION SET NLS_DATE_LANGUAGE = 'SPANISH';
Session altered.
SQL> SELECT TO_CHAR(SYSDATE, 'dy') FROM DUAL;
TO_CHAR(SYSD
------------
mar
SQL> -- This will work even though our session is still in Spanish.
SQL> SELECT TO_CHAR(SYSDATE, 'dy', 'NLS_DATE_LANGUAGE=''ENGLISH''') FROM DUAL;
TO_CHAR(SYSD
------------
tue
SQL>
2条答案
按热度按时间7xzttuei1#
使用sys用户编译它..样本触发:
rhfm7lfc2#
你确定这是英语资料库吗?您可以在
TO_CHAR
中硬编码该语言,而无需更改系统或会话NLS参数。这可能比记住Oracle周是从1还是0开始,或者在您的特定区域设置中是从星期日还是星期一开始更好。(今天是星期二,我正在测试这个。