Logon trigger to alter the session parameter
Hi,
I want to execute alter session set '_b_tree_bitmap_plans'=false;
for a user once he logs in.
I guess it is possible using logon trigger, pls let me know how to?
Thanks,
Kumar.
Ensure that the usage of the statements or settings in the login files is necessary or correct before using it.
For all users, use glogin.sql. This is located in $ORACLE_HOME/sqlplus/admin
For each user, use[b] login.sql. This need to be created by the user from sqlplus using the default editor. e.g type ed login at the SQL prompt. This enables the file to be created at the correct home of the OS user(different between Unix and Windows). Note that it is per OS user and not per Oracle user. For instance, every user who connects to the Server as the OS user oracle will run the same login.sql.
If you enter statements that require logon (just like yours), you will get "Not Connected" error if you normally do sqlplus /nolog. But you will not get it is you connect directly be specifying the username directly or when prompted.
The scripts will be run at each logon (either by typing sqlplus from os command prompt or using connect command within sqlplus).
Similar Messages
-
Need help resetting the SESSIONS parameter
Hi Folks,
Environment: Oracle 10g Rel 2
I am trying to reduce the number of sessions to the database as follows
*# Snap shot of existing values*
show parameters session;
show parameters processes;
show parameters transactions;
sessions integer 170
processes integer 150
transactions integer 187*# Modifying the SESSION parameter value*
alter system set sessions=3 scope=spfile;*# Bounce the instance*
shutdown immediate; *# Startup the instance*
startup;*# Verify if the new value took effect*
show parameters session;
Output: sessions integer 170*# Check if the new value exists in spfile*
select NAME||','||VALUE||','||DISPLAY_VALUE||','||ISSPECIFIED
from v$spparameter
where NAME like 'session%'
Output: sessions,3,3,TRUE*# Verify, if the database was started with the spfile*
SELECT DECODE(value, NULL, 'PFILE', 'SPFILE') "Init File Type"
FROM sys.v_$parameter WHERE name = 'spfile'
Output:
Init F
SPFILEAny ideas as to why the SESSIONS parameter would not take effect?
Thanks in advance
rogers42The sessions parameter is derived from the processes parameter, and in most cases there should be no reason to set it, and leave it untouched.
Setting sessions to 3 is utterly, utterly silly as the background processes count as sessions too.
This might be another reason why Oracle fortunately choose to ignore your change.
You should spend some more time on reading documentation, to avoid new attempts to wreck Oracle and create more havoc.
Sybrand Bakker
Senior Oracle DBA -
Define session parameter for a user
Hi,
in 10g R2, can we set a session parameter for a user definitely ?
I mean to avoid running the following command line at the begining of each session :
alter session his_parameter=somevalue;
Thank you.Hi,
The only way I know to do this is to create a logon trigger that execute the "alter session" command.
Liron Amitzi
Senior DBA consultant
[www.dbsnaps.com]
[www.orbiumsoftware.com] -
How to fire a schema trigger from outside the schema
A user is using an ad hoc tool similar to SQL Developer called PeopleSoft Application Designer.
He creates a connection to the db, then issues an alter session set current_schema = 'restricted_schema'. The connected user does not have direct privileges on the "restricted_schema" which they call SYSADM.
After changing the schema context in that manner he creates objects in SYSADM. A schema trigger is then fired and grants privileges on the new objects created in SYSADM. Doing the same in either SQL Plus or SQL Developer does not fire the schema trigger.
I think SQL Plus and SQL Dev are working as they should. Altering the session like that does not change your identity - just the schema context. But, when you examine v_$session, the connection with this other tool looks exactly the same as one from SQL Plus or SQL Dev when changing the schema context in the session.
Instead of trying to figure out what this other tool is doing, is there any way for that schema trigger to fire when using this process from one of our tools?>
A user is using an ad hoc tool similar to SQL Developer called PeopleSoft Application Designer.
He creates a connection to the db, then issues an alter session set current_schema = 'restricted_schema'. The connected user does not have direct privileges on the "restricted_schema" which they call SYSADM.
After changing the schema context in that manner he creates objects in SYSADM. A schema trigger is then fired and grants privileges on the new objects created in SYSADM. Doing the same in either SQL Plus or SQL Developer does not fire the schema trigger.
>
The user CANNOT create objects in any schema without the proper privileges.
Setting the current_schema parameter does not confer ANY additional privileges to a user. See ALTER SESSION in the SQL language doc
http://docs.oracle.com/cd/E14072_01/server.112/e10592/statements_2013.htm
>
CURRENT_SCHEMA
Syntax:
CURRENT_SCHEMA = schema
The CURRENT_SCHEMA parameter changes the current schema of the session to the specified schema. Subsequent unqualified references to schema objects during the session will resolve to objects in the specified schema. The setting persists for the duration of the session or until you issue another ALTER SESSION SET CURRENT_SCHEMA statement.
This setting offers a convenient way to perform operations on objects in a schema other than that of the current user without having to qualify the objects with the schema name. This setting changes the current schema, but it does not change the session user or the current user, nor does it give the session user any additional system or object privileges for the session.
>
If the user connects and sets SYSADM as the current schema and creates objects in SYSADM the user already had privileges to create objects in the SYSADM schema; setting the current schema has nothing to do with it.
So your issue is that the user has privileges to create objects in the SYSADM schema; you need to revoke those privilges (or the role that grants them) to solve your problem. -
Logon trigger not working over DB-Link?
Hi all,
I have a serious question about accessing tables over a database link.
I have three schema:
DATA@SOURCE
INTERFACE@SOURCE
WORK@TARGET
Schema DATA has one table called T1
The INTERFACE schema has select privileges on all tables from DATA. Furthermore schema INTERFACE has a logon trigger to change the "current schema" to DATA:
CREATE OR REPLACE TRIGGER TRG_A_LOGIN_SET_SCHEMA AFTER LOGON
ON INTERFACE.SCHEMA
BEGIN
execute immediate 'ALTER SESSION SET CURRENT_SCHEMA = DATA';
END;
The WORK schema has a database link to the INTERFACE schema called INT_DB_LINK.
I am now logged into schema WORK on the TARGET database and I am executing following statement:
select a from T1@INT_DB_LINK
-> it's working
Next I execute
declare
cursor c is
select a
from T1@INT_DB_LINK
where rownum<2;
begin
for r in c loop
null;
end loop;
end;
This is not working. Error message is ORA-000942: table or view does not exist.
But why?
Can anyone help me?
Thanks in advance
PyHi all,
after a long, very long search I found what caused this strange behaviour.
The ORA- Error was not raised by the SQL-Execution-Engine but by the SQL-Parser/SQL-Validation.
As the second statement is an anonymous SQL block the Oracle Parser checks all objects dependencies before execution.
This means a connection is established from TARGET to SOURCE checking if table T1 is available. The strange thing is
that on this connection the "ALTER SESSION" trigger is not fired. So the parser does not find object T1 in schema INTERFACE.
If I create an empty table T1 in INTERFACE the anonymous block gets parsed/validated and the statement is executed. But this
time the block does a normal "connect session" and the trigger is fired. This means the statements accesses the T1 table in
schema DATA. (But T1 in INTERFACE has to be existent that parse/validation works)
I don't know if this is a bug or a feature.
To workaround this I have created private synonyms in schema INTERFACE pointing to the objects in DATA.
Thanks for your help!
Py
regarding the other qestion:
Yes, permissions are granted over a role. -
Automatic setup of Oracle session parameter nls_sort?
Hi,
Is there a way to automatically set up the Oracle session parameter when connecting to Oracle?
Much like the .profile file does when logging into Linux.
The session parameter in question is nls_sort. It seems the only way to set nls_sort to BINARY_CI
is to invoke the command after connection:
alter session set nls_sort = 'BINARY_CI'.
But if I am using third party jdbc connection that does not allow the insertion of the alter session command,
I am out of luck. I cannot run the sort using case insensitive mode.
Is there any other alternative that would enable BINARY_CI.
I tried to put it in initXXX.ora, but it did not work.
I appreciate the replies and helps.
Andrew Kuser643072 wrote:
Is there any other alternative that would enable BINARY_CI.
I tried to put it in initXXX.ora, but it did not work.That's maybe because NLS_SORT is derived from NLS_LANGUAGE which is itself derived from NLS_LANG, client setting env variable.
That means, to avoid to use a trigger, and to take in account your init.ora setting, you may need to change the client local settings.
What is the NLS_LANG value of the client ?
Nicolas.
PS: sorry, didn't know what Werner explained earlier : "...because JDBC ignores NLS_LANG settings."
Edited by: N. Gasparotto on Jun 2, 2009 9:33 PM -
How to set the resource_limit parameter to each user
how to set the resource_limit initialization parameter to each user.
it says like this;
You must modify the RESOURCE_LIMIT initialization parameter. After you assign profiles to users, the Oracle database
enforces the limits only when the RESOURCE_LIMIT parameter is set to TRUE. Therefore, you modify the RESOURCE_LIMIT initialization parameter to enforce the resource limits defined within each user's profile.
alter system set resource_limit=true;
if doing like this is it ok. ????
Assume im logged as user "SYS". so if i use this command, will it alter the resource_limit parameter for this user SYS only OR for the entire database..... (for all other user)The RESOURCE_LIMIT parameter only enables resource limits that are defined in profiles.
The DEFAULT profile, by default, is UNLIMITED for all resources.
You should create a custom profile and set the limits you need. The next step would be to assign that profile to the users whom you want to limit. Other users in other profiles (or in the DEFAULT profile) would not have any limits enforced.
See the documentation on CREATE PROFILE.
See http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_6010.htm#i2065930 -
Hi,
I have two SCCM environments under same active directory domain and one service account have been used for SCCM configurations on both the environments (QA and PRODUCTION). I am facing similar error as mentioned above while trying to fetch reports on
PRODUCTION site, but the QA site is working fine, though same service account have been used for configuring both. While looking at the reportserverservice_<date> log on my Production DB server i see the following error
"processing!ReportServer_0-3!2124!01/02/2015-09:09:30:: e ERROR: Throwing Microsoft.ReportingServices.ReportProcessing.ProcessingAbortedException: , Microsoft.ReportingServices.ReportProcessing.ProcessingAbortedException: An error has occurred during
report processing. ---> Microsoft.ReportingServices.ReportProcessing.ReportProcessingException: Cannot read the next data row for the dataset DataSet1. ---> System.Data.SqlClient.SqlException: Conversion failed when converting the nvarchar value 'Override
Default' to data type int."
My DB and SCCM primary site are different and the reorting services point is installed on remote DB server. Please help me resolving the issue.
Troubleshooting performed:
1.Disabled the registry key 'EnableRbacReporting' from HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\SMS\SRSRP to 0 and then restarted SSRS service and the reporting worked for some minutes after that the registry key reverted back to 1 automatically and
reporting started throwing errors again.
2. Checked with the permissions on DB whether or not 'sysadmin' role is assigned to the SCCM service account.
3. re-registered the SQL management Provider WMI class.
mofcomp.exe “C:\Program Files (x86)\Microsoft SQL Server\110\Shared\sqlmgmproviderxpsp2up.mof”Hi All,
Finally found exact solution to the reporting error.
Error: while launching SCCM reports (both from Console and web based) an unexpected error occured with error message as "The DefaultValue expression for the report parameter ‘UserTokenSIDs’ contains an error: A specified logon session does not exist.
It may already have been terminated. (rsRuntimeErrorInExpression)"
Solution: This is password replication issue for the domain account used to configure reporting services point in SCCM. If your SQL SSRS reporting services instance and databse runs with local default account whereas the reporting services point on SCCM
primary site is configured with domain account, (As in My case) you need to perform the following in order to get rid of the error.
Launch 'Reporting Services Configuration Manager' from the SQL SSRS box(either Local or Remote), Connect to Report Server Instance->Go to 'Execution Account' tab->Specify the 'Execution Account' as domain account and password which is used to configure
Reporting Services Point in SCCM Primary Site, and then click apply.
Now Lauch the report either way (Web based or from Console), the error will disappear and all your default reports will execute perfectly as before. -
What is the relationship between Process and Session parameter in Oracle
Hi All
I ran into a problem
"ORA-00020: maximum number of processes (150) exceeded " on the other day and I want to fix this temporary by increase the process by some number like 200.
Someone suggesting the syntax to fix my problem then the database must restart after running this command.
alter system set processes=200 scope=spfile;
However, I check the v$Paramenter view I see 2 values I believe they go together are
Processes: 150
Sessions:170.
Here are my questions:
1. "alter system set processes=200 scope=spfile;" is the correct way to increase the max Processes?
2. Do I have change the number of Sessions after changing the number of Processes?
3. Is there other way to increase the processes number without reboot the Oracle database?
Regards,
JdangAccording to the Oracle version# Reference manual which documents the database parameters sessions is set to 1.1 * process + 5 using the 10gR2 version.
Basically an Oracle process cooresponds to an OS process that performs the actual work for the session.
An Oracle session is a collection of memory structure entries that identifies and keeps track of what is being done for a client of the Oracle database.
Sometimes a single background process will support multiple sessions even in dedicated server mode such as when recursive SQL is performed to support the DML statement being done in the session.
PS - you should consider increasing processes first and only increase sessions if you still have an issue.
HTH -- Mark D Powell --
Message was edited by: mdp add PS
mpowel01 -
Closing DBA session in AFTER LOGON trigger
Hello *,
this is my first question here and my first piece of code in oracle so please don't laugh ;-)
I'm trying to create an AFTER LOGON trigger which disconnects a user if he/she tries to log in from an incorrect host.
What should happen?
User tries to connect.
If he/she is permitted, a record is added to a table.
If not, a record is added to another table and the user is disconnected using RAISE_APPLICATION_ERROR().
After a number of issues I've got it working, except ... I have the feeling that RAISE_APPLICATION_ERROR() doesn't effect users with DBA privileges.
Finally, I'm testing it with one ordinary user - DEF.
The main idea is to disallow connections from user ABC which has DBA privileges.
Tests using DEF are successful but when ABC tries to log in from an incorrect host, a record is added in pcbaudit_failed_logins but the user is not disconnected.
The database is 9.2.0.8.0 and I'm prepared to post RDA report if it is required.
Thank you for your help in advance - I hope I was kind enough :P
Here's the code for the trigger:
DROP TABLE pcbaudit_users;
CREATE TABLE pcbaudit_users (username VARCHAR2(32) NOT NULL, host VARCHAR2(64) NOT NULL);
CREATE INDEX idx_pcbaudit_users_username ON pcbaudit_users(username);
CREATE INDEX idx_pcbaudit_users_host ON pcbaudit_users(host);
DROP TABLE pcbaudit_logins;
CREATE TABLE pcbaudit_logins (username VARCHAR2(32), ip_address VARCHAR2(15), host VARCHAR2(64), ts DATE);
DROP TABLE pcbaudit_failed_logins;
CREATE TABLE pcbaudit_failed_logins (username VARCHAR2(32), ip_address VARCHAR2(15), host VARCHAR2(64), ts DATE);
CREATE OR REPLACE PUBLIC SYNONYM pcbaudit_users FOR sys.pcbaudit_users;
CREATE OR REPLACE PUBLIC SYNONYM pcbaudit_logins FOR sys.pcbaudit_logins;
CREATE OR REPLACE PUBLIC SYNONYM pcbaudit_failed_logins FOR sys.pcbaudit_failed_logins;
GRANT SELECT ON sys.pcbaudit_users TO public;
GRANT INSERT ON sys.pcbaudit_logins TO public;
GRANT INSERT ON sys.pcbaudit_failed_logins TO public;
INSERT INTO pcbaudit_users VALUES ('SYS', '%');
INSERT INTO pcbaudit_users VALUES ('SYSTEM', '%');
INSERT INTO pcbaudit_users VALUES ('ABC', '%');
INSERT INTO pcbaudit_users VALUES ('DEF', '%');
COMMIT;
CREATE OR REPLACE
TRIGGER logon_pcbaudit_trigger AFTER LOGON ON DATABASE
DECLARE
v_username VARCHAR2(32); /* variable that will hold current username */
v_host VARCHAR2(4000); /* variable that will hold current host */
v_allowed NUMBER(1) := 0;
PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
SELECT UPPER(USER), /* current user */
UPPER(SYS_CONTEXT('USERENV', 'HOST')) /* current user host */
INTO v_username,
v_host
FROM dual;
/* debug */
-- DBMS_OUTPUT.PUT_LINE(v_username || '@' || v_host);
SELECT 1
INTO v_allowed
FROM pcbaudit_users
WHERE UPPER(username) = v_username
AND (
UPPER(REPLACE(v_host, CHR(0), '')) LIKE UPPER(host) ESCAPE '!' /* fuck that shit! Something appends CHR(0) to its host... */
OR
v_host IS NULL /* fuck that shit! Some hosts are NULLs! */
/* write log (user has logged in!) */
INSERT
INTO pcbaudit_logins
(username, ip_address, host, ts)
VALUES
(v_username, SYS_CONTEXT('USERENV', 'IP_ADDRESS'), v_host, SYSDATE);
COMMIT;
EXCEPTION
WHEN NO_DATA_FOUND THEN /* occurs when no matches were found; i.e. current username is not permitted to login from the current host */
/* log the failed attempt */
INSERT
INTO pcbaudit_failed_logins
(username, ip_address, host, ts)
VALUES
(v_username, SYS_CONTEXT('USERENV', 'IP_ADDRESS'), v_host, SYSDATE);
COMMIT;
/* disconnect user */
RAISE_APPLICATION_ERROR(-20001, v_username || '@' || v_host || ' is not allowed to connect.');
WHEN OTHERS THEN
NULL; /* in this case, NULL is better than an error - if an error occurs, user will not be able to login. */
END;Thank you for your reply!
The situation is quite complicated.
I am aware that a user with DBA privileges can drop the trigger, modify it, etc.
There's an application on top of it and (i don't know why) it requires dba privileges. The point is, there are developers with access to the production database and my task is to stop them from logging in with this username.
Since I'm creating a trigger, I've obviously have no other choice. I can't change the user's password because of number of reasons, I can't deny developers' IP addresses using sqlnet.ora because they need read-only access and so on.
I realize that this is not the way that things are being done (development cycle), but I have no other choice.
So, is there any other way? -
Alter the tablespace storage parameter
Hi,
I want to alter the tablespace storage parameter from 1024 to 200 KB. Can anyone please provide me what is the procedure? Its very urgent.
SumanSQL> select tablespace_name, EXTENT_MANAGEMENT, ALLOCATION_TYPE, SEGMENT_SPACE_M
ANAGEMENT from dba_tablespaces;
Output of the sql
TABLESPACE_NAME EXTENT_MAN ALLOCATIO SEGMEN
SYSTEM DICTIONARY USER MANUAL
PSAPR3E LOCAL SYSTEM MANUAL
PSAPR3E620 LOCAL SYSTEM MANUAL
PSAPR3EUSR LOCAL SYSTEM MANUAL
PSAPTEMP LOCAL UNIFORM MANUAL
PSAPTF60D LOCAL SYSTEM MANUAL
PSAPUNDO LOCAL SYSTEM MANUAL
SYSAUX LOCAL SYSTEM AUTO
<u><b>PSAPR3E700 LOCAL UNIFORM AUTO</b></u>
Message was edited by:
Amit Jain -
Apex Version 4.2: Why doesn't the session timeout parameter settings work?
Prior to an upgrade to Apex Version 4.2.0.00.27, we ran Apex Version 4.1 in our environment. This is on a platform using Oracle Database Enterprise Edition 11g R2 on Windows Server 2008. The session timeout parameters (set for a single application using "Shared Components" -> "Security Attributes") were set to the following:
Maximum Session Time: 1 day
Maximum Session Idle Time: 8 hours
This worked with no problems in Apex 4.1; our user would leave a data entry form open for several hours, complete the data entry then submit the page. Now, with the upgrade to Apex 4.2, doing the same thing causes the system to redirect to the login page and aborting any edits or new data entered into the form previously.
I have tried to set both session parameters to ZERO (0) which is what the documentation explains is the equivallent to "no timeout" but that didn't work as well.
I have reset the session control parameters to what they were before the upgrade and my session times out before the time values I set. (on the version 4.2 upgraded instance).
Why was the session timeout parameters I set ignored by the system? Can anyone else out there confirm/repeat the problem I observed?Hi Richard,
You probable have it ok, but the time should be in seconds.
Kees -
Inccreasing the timeout parameter for the Oracle R12 session
Hi ,
We have set profile ICX:SESSION TIME OUT to be 45. But it seems the session times out very quickly. How can this time out be increased ?
WE are on R12.0.4.
Best regards,
brindaHi brinda;
Please check below and see its helpful for your issue,this topic discussed beforei belive you will get some answer(maybe more) in them
EBS connection time out
Re: ICX : Session Timeout
Forms session timeout
[Link1|http://www.solutionbeacon.com/best7.htm]
Regard
Helios -
Logon trigger setting nls_date_format over ridden by sql developer?
Problem: Developers are inserting a Date record into a varchar field. I can't change this process right now. Non-Date info is stored here also. Would require a code change.
To simplify this, I wanted to get all the developers to insert using the same 'nls_date_format'. I had hoped to be able to centralize this by having Oracle set it in the database. I tried this by setting the database nls_date_format and with a logon trigger.
See test below. Seems to be over ridden.
Test case is with SQL Developer. Noticed the same thing when developers use Websphere. I think we reduce the chance for errors, if I can handle this in the database. However, my nls_date_format settings are getting over ridden.
1. s et database parameter nls_date_format to YYYY-MM-DD HH24:MI:SS , this gets over riden by SQL Developer/Websphere
2. Created a trigger with an 'alter session', but this seems to get over ridden also.
Please see test case below:
Oracle 11.2.0.3
test logging: SQLPLUS locally on the unix server, then log in using SQL Developer which is installed on my laptop.
SQL Developer NLS_DATE_FORMAT : YYYY-MON-DD HH24:MI:SS , This is different for test purposes
I have auditing turned turned on to db,extended with 'audit all by 'user' by access;' for test purposes to get more info.
create table test (username varchar2(30),sid number,mytest varchar2(300),insert_date date);
create or replace
TRIGGER LOGINTRG
AFTER LOGON ON DATABASE
BEGIN
insert into test select user, sys_context('USERENV','SID') ,value,sysdate from v$parameter where name = 'nls_date_format';
EXECUTE IMMEDIATE 'ALTER SESSION SET NLS_DATE_FORMAT=''YYYY-MM-DD HH24:MI:SS''';
insert into test select user, sys_context('USERENV','SID') ,value,sysdate from v$parameter where name = 'nls_date_format';
commit;
END LOGINTRG;
/Results/Questions
1. When I select from 'test', I confirm that my NLS_DATE_FORMAT is the same both before and after the alter session.
2. select value from v$parameter where name = 'nls_date_format'
output: YYYY-MON-DD HH24:MI:SS (so sql developer is over riding this);
3. select * from dba_audit_trail where username = 'MYUSER' order by timestamp desc;
The SQLs from the logon trigger are not captured. how do I capture logon trigger sqls? Not a huge deal, just curious
4. I do not see any alter sessions issued by my user. shouldn't audit all by access capture that? how could my session nls_date_format change without an alter session?
Edited by: Guess2 on Apr 22, 2013 10:44 AM>
Problem: Developers are inserting a Date record into a varchar field.
>
No - they aren't. That is physically impossible. The only thing that can be stored in a 'varchar field' is a string. Oracle considers ANYTHING stored in a character column to be a string.
Date values are stored in DATE columns. Perhaps you meant that developers are converting DATE values to strings and then storing the string in a 'varchar field'?
>
I can't change this process right now. Non-Date info is stored here also.
>
WONDERFUL! Why use a column to stored just one type of data? That is extremely wasteful. Hopefully you store strings that represent numbers in that same column also? It makes the data model so much easier to understand if developers only need to learn one datatype.
>
Would require a code change.
>
The horror!
You should never, ever, EVER use a code change to fix a problem if there is even the slightest possibility that you can change the ENTIRE DATABASE instead.
I've got good news though. You are now on version Oracle 11.2.0.3 and Oracle, after months of protests by some of their largest clients, has finally dropped the exhorbitant license fees for using some of the more esoteric datatypes like DATE and NUMBER.
You should suggest to your manager that they use some of the license fee money saved to hire developers that already know how to design proper data models and use those new-fangled datatypes.
Trust me - once you've made it up that steep learning curve your code will have fewer of those pesky 'dirty data' issues to deal with.
Sure - it means less job security for your current developers. But sometimes you just have to 'take one for the team'! -
Logon Trigger setting NLS_SESSION_PARAMETERS not working
Hello,
I have a problem with a logon trigger setting session parameters:
create or replace
TRIGGER standard.after_logon_trg
AFTER LOGON ON STANDARD.SCHEMA
BEGIN
DBMS_APPLICATION_INFO.set_module(USER, 'Initialized');
EXECUTE IMMEDIATE ('ALTER SESSION SET current_schema=standard');
EXECUTE IMMEDIATE ('ALTER SESSION SET NLS_DATE_LANGUAGE=''AMERICAN''');
EXECUTE IMMEDIATE ('ALTER SESSION SET NLS_TERRITORY=''AMERICA''');
EXECUTE IMMEDIATE ('ALTER SESSION SET NLS_TIMESTAMP_FORMAT=''HH24:mi:ss''');
EXECUTE IMMEDIATE ('ALTER SESSION SET NLS_DATE_FORMAT=''YYYY-MM-DD''');
EXECUTE IMMEDIATE ('ALTER SESSION SET NLS_COMP=LINGUISTIC');
EXECUTE IMMEDIATE ('ALTER SESSION SET NLS_SORT=BINARY_CI');
insert into standard.testcc (bezeichnung, datum) values ('logontrigger', SYSDATE);
END;After I log in, the new row is added to the table, but the session parameters are completely untouched.
select * from NLS_SESSION_PARAMETERS says:
NLS_LANGUAGE GERMAN
NLS_TERRITORY GERMANY
NLS_CURRENCY €
NLS_ISO_CURRENCY GERMANY
NLS_NUMERIC_CHARACTERS ,.
NLS_CALENDAR GREGORIAN
NLS_DATE_FORMAT DD.MM.RR
NLS_DATE_LANGUAGE GERMAN
NLS_SORT GERMAN
NLS_TIME_FORMAT HH24:MI:SSXFF
NLS_TIMESTAMP_FORMAT DD.MM.RR HH24:MI:SSXFF
NLS_TIME_TZ_FORMAT HH24:MI:SSXFF TZR
NLS_TIMESTAMP_TZ_FORMAT DD.MM.RR HH24:MI:SSXFF TZR
NLS_DUAL_CURRENCY €
NLS_COMP BINARY
NLS_LENGTH_SEMANTICS BYTE
NLS_NCHAR_CONV_EXCP FALSEIf I execute the ALTER SESSION statements in the sql console (as user standard) they work perfectly, so this seems to be no permission issue.
Whats wrong with the trigger?
Thanks and regards
Christian
Edited by: 853536 on 20.04.2011 00:31
OK, I've traced the entire database, and found out that my parameters are overwritten. So after my trigger has been executed, the NLS Session parameters are altered, for example:
=====================
PARSING IN CURSOR #4 len=386 dep=0 uid=40 oct=3 lid=40 tim=4721509708 hv=302297662 ad='ab275c28'
select parameter,value from nls_session_parameters
union all SELECT 'DB_TIMEZONE' name, DBTIMEZONE value FROM DUAL
union all SELECT 'SESSION_TIMEZONE' name, SESSIONTIMEZONE value FROM DUAL
union all SELECT 'SESSION_TIMEZONE_OFFSET' name, TZ_OFFSET(SESSIONTIMEZONE) value from DUAL
union all SELECT parameter, value FROM nls_database_parameters WHERE parameter='NLS_CHARACTERSET'
END OF STMT
PARSE #4:c=0,e=3962,p=0,cr=4,cu=0,mis=1,r=0,dep=0,og=1,tim=4721509705
EXEC #4:c=0,e=21,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=1,tim=4721509816
FETCH #4:c=0,e=111,p=0,cr=0,cu=0,mis=0,r=10,dep=0,og=1,tim=4721509976
FETCH #4:c=0,e=132,p=0,cr=0,cu=0,mis=0,r=10,dep=0,og=1,tim=4721510598
FETCH #4:c=0,e=204,p=0,cr=3,cu=0,mis=0,r=1,dep=0,og=1,tim=4721511118
STAT #4 id=1 cnt=21 pid=0 pos=1 obj=0 op='UNION-ALL (cr=3 pr=0 pw=0 time=264 us)'
STAT #4 id=2 cnt=17 pid=1 pos=1 obj=0 op='FIXED TABLE FULL X$NLS_PARAMETERS (cr=0 pr=0 pw=0 time=128 us)'
STAT #4 id=3 cnt=1 pid=1 pos=2 obj=0 op='FAST DUAL (cr=0 pr=0 pw=0 time=1 us)'
STAT #4 id=4 cnt=1 pid=1 pos=3 obj=0 op='FAST DUAL (cr=0 pr=0 pw=0 time=0 us)'
STAT #4 id=5 cnt=1 pid=1 pos=4 obj=0 op='FAST DUAL (cr=0 pr=0 pw=0 time=1 us)'
STAT #4 id=6 cnt=1 pid=1 pos=5 obj=96 op='TABLE ACCESS FULL PROPS$ (cr=3 pr=0 pw=0 time=194 us)'
=====================
PARSING IN CURSOR #3 len=41 dep=0 uid=40 oct=42 lid=40 tim=4721512239 hv=2321140216 ad='ab275184'
alter session set NLS_TERRITORY='GERMANY'
END OF STMT
PARSE #3:c=0,e=329,p=0,cr=0,cu=0,mis=1,r=0,dep=0,og=1,tim=4721512236
EXEC #3:c=0,e=48,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=1,tim=4721512424
=====================
PARSING IN CURSOR #2 len=35 dep=0 uid=40 oct=42 lid=40 tim=4721513208 hv=2785092162 ad='ab274e88'
alter session set NLS_SORT='GERMAN'
END OF STMT
PARSE #2:c=0,e=283,p=0,cr=0,cu=0,mis=1,r=0,dep=0,og=1,tim=4721513205
EXEC #2:c=0,e=20,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=1,tim=4721513370
=====================
...This explains why they are overwritten, but I still don't know why the session parameters are altered after my trigger at all. Any idea?
Edited by: 853536 on 20.04.2011 01:24
Problem solved: I was using Oracle SQL Developer to edit my trigger and to try it - and SQL Developer seems to ovewrite the NLS_Session parameters. Duh.
Edited by: 853536 on 20.04.2011 02:04Yes, SQL Developer will usually override the settings. It should not do this if you go to Tools->Preferences->Database->NLS and check "Skip NLS Settings".
But, any program using JDBC OCI will also override most of the settings. Therefore, you should not rely on the database to fix the NLS settings. It is applications' job to prepare the NLS environment correctly (if the standard initialization based on the O/S settings and/or NLS_LANG is not satisfactory).
-- Sergiusz
Maybe you are looking for
-
Creating TOC Bookmarks in a PDF created from Microsoft Word
Does anyone know how to modify PDF creation settings so that bookmarks are automatically set from the Table of Contents in the PDF version of a Microsoft Word document? This is possible in Windows using word and Acrobat Pro. But it's not automatic in
-
I want to use a nas drive for my time machine back ups.
Hi, I'm pretty new to macs. I've set up time machine on my kids macs using a time capsule without problems. Ive now bought my own mac and want to use time machine to back it up but only have a network hard drive to do it on. When I go to choose disk,
-
OTA update for A10-70 failed "no command"
I just updated using the OTA update available for my A10-70 and when it rebooted, it says "No command" . I can get to the recovery, and I tried doing a factory reset on it, but the tablet still won't boot. Any ideas? Is there a factory image I can
-
Hello, I wrote the following code : Javax.swing.JTextArea siwngTextArea = new Javax.swing.JTextArea(); Java.awt.TextArea awtTextArea = new java.awt.TextArea(); � for (int i = 0; i < 100; i++){ System.out.println(�S�+i); swingTextArea.append(�S�+i); a
-
I understand it is a good idea for both safety and speed to keep the lrcat on the hard drive. All my photos are stored on an EHD, as is, currently, my lrcat. Since I have gotten into trouble moving things around, I'd like to hear how to move the lr