For a JDBC application I need to issue a few ALTER SESSION commands. I do not want to put those into the application code itself. Is there a way to specify defaults for the session parameters for the database schema that the application uses (on the database side) ?
A:
I haven't tested this, but could you make the application call a stored procedure that set the session variables whenever a session is created? Then, you could modify the stored procedure on the server side when needed.
Plasmer
2009-09-14 06:40:24
The point is to not change the application code at all. If I change it to include some actions on session creation (such as call a stored procedure), I would probably make these actions configurable (such as reading them from a file), so that I might as well include the ALTER SESSION calls directly.
Thilo
2009-09-14 06:45:01
+4
A:
Hi Thilo,
most session parameters are defined by the client application. If you want to override the client settings you could create a DATABASE TRIGGER
. For example, this will create a LOGON
trigger on the BAR
schema:
CREATE OR REPLACE TRIGGER bar.foo
AFTER LOGON ON DATABASE WHEN (USER = 'BAR')
BEGIN
dbms_session.set_nls('NLS_NUMERIC_CHARACTERS', '''.,''');
EXECUTE IMMEDIATE 'ALTER SESSION SET CURRENT_SCHEMA=hr';
END foo;
Vincent Malgrat
2009-09-14 07:57:39
An on-logon database trigger is the only way to do this without an application code change.
mathewbutler
2009-09-14 08:03:17