Alter session when login
Hi,
on 11G R2,
I want that user3 change session to user2 just on connection. How is it possible ?
I want to avoid user3 to issue :
ALTER SESSION SET CURRENT_SCHEMA =USER2at each connection.
Thanks for help.
it working , see this
SQL> conn hr
Enter password:
Connected.
SQL> select PRIVILEGE from session_privs ;
PRIVILEGE
CREATE SESSION
ALTER SESSION
UNLIMITED TABLESPACE
CREATE TABLE
CREATE CLUSTER
CREATE SYNONYM
CREATE VIEW
CREATE SEQUENCE
CREATE DATABASE LINK
CREATE PROCEDURE
CREATE TRIGGER
CREATE TYPE
CREATE OPERATOR
CREATE INDEXTYPE
ADMINISTER DATABASE TRIGGER
15 rows selected.
SQL> conn scott
Enter password:
Connected.
SQL> select PRIVILEGE from session_privs ;
PRIVILEGE
CREATE SESSION
UNLIMITED TABLESPACE
CREATE TABLE
CREATE CLUSTER
CREATE SEQUENCE
CREATE PROCEDURE
CREATE TRIGGER
CREATE TYPE
CREATE OPERATOR
CREATE INDEXTYPE
ADMINISTER DATABASE TRIGGER
11 rows selected.
SQL> conn hr
Enter password:
Connected.
SQL> CREATE OR REPLACE TRIGGER set_after_logon AFTER LOGON ON DATABASE
BEGIN
execute immediate 'ALTER SESSION SET CURRENT_SCHEMA = SCOTT';
END;
/ 2 3 4 5
Trigger created.
SQL> conn scott
Enter password:
Connected.
SQL> CREATE OR REPLACE TRIGGER set_after_logon AFTER LOGON ON DATABASE
BEGIN
execute immediate 'ALTER SESSION SET CURRENT_SCHEMA = HR';
END;
/ 2 3 4 5
Trigger created.
SQL> conn scott
Enter password:
Connected.
SQL> set serverout on
SQL> exec dbms_output.put_line(SYS_CONTEXT('USERENV','CURRENT_SCHEMA'));
HR
PL/SQL procedure successfully completed.
SQL> conn hr
Enter password:
Connected.
SQL> set serverout on
SQL> exec dbms_output.put_line(SYS_CONTEXT('USERENV','CURRENT_SCHEMA'));
HR
PL/SQL procedure successfully completed.
SQL> select owner,trigger_name from dba_triggers where trigger_name like '%AFTER_LOGON%';
OWNER TRIGGER_NAME
SCOTT SET_AFTER_LOGON
HR SET_AFTER_LOGON
OWNER NAME TYPE LINE TEXT
SCOTT SET_AFTER_LOGON TRIGGER 1 TRIGGER set_after_logon AFTER LOGON ON DATABASE
SCOTT SET_AFTER_LOGON TRIGGER 2 BEGIN
SCOTT SET_AFTER_LOGON TRIGGER 3 execute immediate 'ALTER SESSION SET CURRENT_SCHEMA = HR';
SCOTT SET_AFTER_LOGON TRIGGER 4 END;
HR SET_AFTER_LOGON TRIGGER 1 TRIGGER set_after_logon AFTER LOGON ON DATABASE
HR SET_AFTER_LOGON TRIGGER 2 BEGIN
HR SET_AFTER_LOGON TRIGGER 3 execute immediate 'ALTER SESSION SET CURRENT_SCHEMA = SCOTT';
HR SET_AFTER_LOGON TRIGGER 4 END;
8 rows selected.but.....
SQL> conn SYSTEM
Enter password:
Connected.
SQL> set serverout on
exec dbms_output.put_line(SYS_CONTEXT('USERENV','CURRENT_SCHEMA'));SQL>
HR
PL/SQL procedure successfully completed.
since it set at db level so it get fired for all user who login at db until you specify the condition in trigger for specific user
Similar Messages
-
EA2 - invalid option for ALTER SESSION when logging in to 9i DB via EA2
When logging in to a 9i DB(9.2.0.7.0) i recieve the following error in the Logging Window:
SEVERE 48 16 ORA-02248: invalid option for ALTER SESSION
Edited by: Trotty on Nov 10, 2009 10:37 AM
Does anyone else get this logging message when accessing a 9i DB
Edited by: Trotty on Nov 10, 2009 10:37 AMTrotty wrote:
When logging in to a 9i DB(9.2.0.7.0) i recieve the following error in the Logging Window:
SEVERE 48 16 ORA-02248: invalid option for ALTER SESSION
Edited by: Trotty on Nov 10, 2009 10:37 AM
Does anyone else get this logging message when accessing a 9i DBI use 10g but have never seen that message even on 9i.
See if you have any on-login triggers that could be issuing an incorrect alter session command. Also see if the error occurs as other users (if possible)
If this was SQL*PLUS I'd also check the login.sql and glogin.sql files but I don't think sql*developer uses those.
Edited by: riedelme on Nov 10, 2009 6:18 AM -
ORA-02248: invalid option for ALTER SESSION when logging in from client
Hi,
I am a junior dba and I was hoping if someone could help me out with a problem I am having. I recently installed on oracle 10g client on my windows machine. I am trying to remote connect to my database on a unix box but I am getting the below error when trying to connect from the client.
ERROR:
ORA-00604: error occurred at recursive SQL level 1
ORA-02248: invalid option for ALTER SESSION
I've done some digging around on this and I think it might be something to do with the NLS_LANG setting maybe. I'm not sure though and to be honest I'm a bit lost on this.
Any help would be greatly appreciated. Cheers.
Rgs,
RobPlease see below
BANNER
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
CORE 11.2.0.1.0 Production
TNS for Linux: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production -
Insufficient privileges when creating MV with alter session set current_sch
I am getting Insufficient privileges when creating MV with alter session set current_schema=Application schema name. User running the alter session is DBA user. If run as SYSDBA, MV is created successfully. DB Version is 10.2.0.3
I observed similiar issue with regular View also in 9.2.0.6 also.
Any advice is greatly appreciated.
Thanks,
SivaSounds like your management needs a stern lecture on the concept of change management. <g>
I am not debating what you do. I am questioning the logic, or lack thereof, of doing it that way. My recommendation would be to change your procedure to one that:
A. Is more in line with good change management practices.
B. Works. -
Why does Firefox 'remember' a login from my last session when, on both occasions, I was using "Private Browsing"? How do I stop this (without clearing other data)?
Try disabling hardware acceleration. Many visual bugs can be attributed to issues with graphics drivers.
(Firefox -> Options -> Advanced -> General -> [ ] Use hardware acceleration when available) -
How to tell if a user is issuing 'alter session statements'
When I run 'alter session' from sqlplus in my schema, this does not get parsed and go to v$sql or show up in v$open_cursor. I have a user that is running queries from informatica. He says he is passing alter session statements through informatica, I want to see if they actually get there. The person is not real versed in oracle and I don't know informatica.
i cant turn on trace cause he connects and disconnects and this would run immediately, I am not in a position to turn on system level tracing, add a trigger, or turn on auditing (not allowed).
anyway to tell from a data dictionary view or something like that if these were issued by a given session? The queries run for a few minutes, so I have a bit before his session disconnects to query the data. I can't get him to change his code to stay connected. Is there a view that shows parameter changes for a given session?
oracle: 10.2.0.5
4 alter session commands are:
Alter session set sort_area_size=999999999;
Alter session set hash_area_size=999999999;
Alter session set db_file_multiblock_read_count = 128;
alter session enable parallel dml;
Edited by: Guess2 on Jul 17, 2012 12:49 PMi cant turn on trace cause he connects and disconnects and this would run immediately, I am not in a position to turn on system level tracing, add a trigger, or turn on auditing (not allowed). If Informatica connects to Oracle via network, capturing TCP/IP traffic and mining in it may be your last resort.
you can get session's PDML status from
select pdml_status from v$session;
i cant turn on trace cause he connects and disconnects and this would run immediatelythis contradicts to your following statement
The queries run for a few minutes, so I have a bit before his session disconnects to query the data.
I can't get him to change his code to stay connected. Informatica should have debug. Ask him if he can go step by step.
Edited by: user11181920 on Jul 17, 2012 5:53 PM -
RMAN-10006: error running SQL statement: alter session set remote_dependenc
Backups are failing with following error
RMAN-00554: initialization of internal recovery manager package failed
RMAN-12001: could not open channel default
RMAN-10008: could not create channel context
RMAN-10002: ORACLE error: ORA-00096: invalid value SIGNATURE for parameter remote_dependencies_mode, must be from among MANUAL, AUTO
RMAN-10006: error running SQL statement: alter session set remote_dependencies_mode = signature
Not able to change to signature
SQL> alter session set remote_dependencies_mode=signature;
ERROR:
ORA-00096: invalid value SIGNATURE for parameter remote_dependencies_mode, must
be from among MANUAL, AUTO
I dont see MANUAL or AUTO as valid value for this parameter (http://download.oracle.com/docs/cd/B10501_01/server.920/a96536/ch1175.htm#1023124) DB version is 9.2.0
Parameter type
String
Syntax
REMOTE_DEPENDENCIES_MODE = {TIMESTAMP | SIGNATURE}
Default value
TIMESTAMP
Parameter class
Dynamic: ALTER SESSION, ALTER SYSTEM
=======================================
I believe it could be because of following bug
"A PRE-PATCHED ORACLE IMAGE CAN BE INSTALLED IN MEMORY "
Refer: "https://metalink2.oracle.com/metalink/plsql/f?p=130:15:1613505143885559758::::p15_database_id,p15_docid,p15_show_header,p15_show_help,p15_black_frame,p15_font:BUG,4610411,1,1,1,helvetica"
I appreciate your effort in fixing this issue.
Edited by: user10610722 on Nov 25, 2008 4:37 PMHi:
It seems when you are starting RMAN it's executing some commands (one 'ALTER SESSION...'. It's seems to be a batch which has a bad value for SORT_AREA_SIZE. Find it and modify to a proper value as message shows. If you can't find start RMAN by calling directly the executable ($ORACLE_HOME/bin/rman or %ORACLE_HOME%/bin/rman.exe). -
Oracle Alter Session not working in CF9
Hello,
I'm trying to understand differences between CF5 and CF9 when I retrieve numbers and dates from an Oracle Database.
The code I ran on CF5 and CF9 servers :
<cfoutput>
<cftransaction>
<cfquery datasource="intranet">
alter session SET NLS_TERRITORY = FRANCE
</cfquery>
<cfquery name="qry" datasource="intranet">
select
TO_NUMBER(12345/10) as nbr,
sysdate as dt,
TO_CHAR(1234.56,'L99G999D99') as cur
from dual
</cfquery>
</cftransaction>
#qry.nbr#<br>
#qry.dt#<br>
#qry.cur#
</cfoutput>
I've got those outputs :
Result in CF5
Result in CF9
1234,5
01/12/09
¿1.234,56
1234.5
2009-12-01 19:16:04.0
¿1.234,56
The first two rows in CF5 display data in French format. That's not the same for CF9, the data are in American format.
Then I changed the NLS_TERRITORY parameter
alter session SET NLS_TERRITORY = AMERICA
Result in CF5
Result in CF9
1234.5
01-DEC-09
$1,234.56
1234.5
2009-12-01 19:20:39.0
$1,234.56
The two first row haven't changed in CF9, it seems that the "alter session" has no effect on number and date format in query results. Is that a bug or am I misunderstanding something ?
Regards,
MaximeThank you for your reply.
I tried what you've suggested on the CF9 server.
The results are :
NLS_TERRITORY =
1) oracle JDBC database
2) oracle JDBC thin client
3) oracle JDBC-ODBC bridge
AMERICA
1234.5
2009-12-02 13:24:30.0
$1,234.56
1234.5
{ts '2009-12-02 00:00:00'}
$1,234.56
1234.5
2009-12-02 13:24:30.0
$1,234.56
FRANCE
1234.5
2009-12-02 13:29:53.0
¿1.234,56
1234.5
{ts '2009-12-02 00:00:00'}
¿1.234,56
1234.5
2009-12-02 13:29:53.0
¿1.234,56
The behavior is pretty much the same in the three differents ways to call the database. The only difference is on the date display using the Oracle JDBC thin client, which is another format from those I've already got.
Regards,
Maxime -
Execute immediate 'alter session set current_schema = ' failed in PL/SQL
Hi
I am trying to run
EXECUTE IMMEDIATE 'ALTER SESSION SET CURRENT_SCHEMA = TEST ' ;
in a pl/sql block but it is failing.Can anyone update me on this.
CREATE OR REPLACE PROCEDURE test3
IS
A_COUNT NUMBER(15);
BEGIN
EXECUTE IMMEDIATE 'ALTER SESSION SET CURRENT_SCHEMA = TEST ' ;
SELECT COUNT(*) INTO A_COUNT FROM (
select id from solutions );
END;
/The user who owns the procedure needs to be granted direct select rights on table test.solutions (not via a role). Still will not help. Look what OP is trying to do. In a stored procedure owned by some user (other than TEST) OP is trying to reference user TEST owned table solution without prefixing it with owner. Something like:
SQL> create table u1.test_tbl(x number);
Table created.
SQL> select * from test_tbl;
select * from test_tbl
ERROR at line 1:
ORA-00942: table or view does not exist
SQL> alter session set current_schema = U1;
Session altered.
SQL> select * from test_tbl;
no rows selected
SQL> However, OP tries to do it in a SP using dynamic SQL to change current schema to test. Such change will occur when SP will be executed, not when is it compiled. At compile time we are still under SP owner's schema and therefore select from solutions implies table solutions owned by SP owner, not by TEST. The only way to make SP compile and work OK is to select from solutions also dynamically:
SQL> select sys_context('userenv','current_schema') from dual
2 /
SYS_CONTEXT('USERENV','CURRENT_SCHEMA')
SCOTT
SQL> CREATE OR REPLACE PROCEDURE test3
2 IS
3 A_COUNT NUMBER(15);
4 BEGIN
5 EXECUTE IMMEDIATE 'ALTER SESSION SET CURRENT_SCHEMA = U1' ;
6 SELECT COUNT(*) INTO A_COUNT FROM (
7 select x from test_tbl );
8 END;
9 /
Warning: Procedure created with compilation errors.
SQL> sho err
Errors for PROCEDURE TEST3:
LINE/COL ERROR
6/1 PL/SQL: SQL Statement ignored
7/15 PL/SQL: ORA-00942: table or view does not exist
SQL> set serveroutput on
SQL> CREATE OR REPLACE PROCEDURE test3
2 IS
3 A_COUNT NUMBER(15);
4 c sys_refcursor;
5 BEGIN
6 EXECUTE IMMEDIATE 'ALTER SESSION SET CURRENT_SCHEMA = U1' ;
7 OPEN C FOR 'SELECT COUNT(*) FROM (select x from test_tbl )';
8 FETCH c INTO A_COUNT;
9 dbms_output.put_line(a_count);
10 CLOSE c;
11 END;
12 /
Procedure created.
SQL> insert into u1.test_tbl select rownum from emp;
14 rows created.
SQL> exec test3
14
PL/SQL procedure successfully completed.
SQL> Obviously, as you noted SP owner must have directly granted select on test3.solutions.
SY. -
Hi All,
I have created process to alter session so I control the currency format, any way the process is working fine on the home page, but when visit another page or return to the home page the session value (currency format )will go back to previous setting ($). How can I keep this session consistent and fixed across my website?
Also when I change the order by for any report the currency format will be shown in older setting ($), I’m using PPR reports.
PS, when moving between pages the session state is same doesn't change. Also i have tried both application process and page process on new session and on page load.
Thanks,
Fadi.Sorry to bother you with what should be a very stupid question.
I have tried to use the advice given to set the currency for my APEX application.
I used the VPD call in the security attributes tab for my application:
begin
execute immediate 'alter session set nls_territory=''FRANCE''';
execute immediate 'alter session set nls_currency=''€''';
end;
When applying the changes, the euro symbol (€) is set to a reverse question mark (¿)
I can think of a character set problem but no other clue.
Thanks in advance for any interest in my question,
Daniel -
How to invalidate old sessions when new user access appl on same machine
hi all,
I am using Mozilla browser to access my web application.User one access my application using his credentials .but i left that browser open.after that I am opening the another Mozilla window and accessing my application using different credentials ex:user2 credentials .user 2 also can access my application.but when i open the first browser ..am automatically getting second user session.how can we avoid this problem.
Application is using session identifier(jSessionID) as the URL parameter for session management.
is it possible to invalidate the old session when new user access on same machine.
thanks,
VishnuVishnuReddy wrote:
hi all,
I am using Mozilla browser to access my web application.User one access my application using his credentials .but i left that browser open.after that I am opening the another Mozilla window and accessing my application using different credentials ex:user2 credentials .user 2 also can access my application.but when i open the first browser ..am automatically getting second user session.how can we avoid this problem.That shouldn't occur. Either you explained it the wrong way (or I interpreted it the wrong way), or there's huge bug in your login/logout logic. After opening another window inside the same session, you should still be logged in as the first user. -
ALTER SESSION executed before every select statement
When I log what the oracle jdbc driver is doing I see the following before EVERY select statement:
ALTER SESSION SET ISOLATION_LEVEL = READ COMMITTED
I know what this means and that it is the oracle default, but:
as this is the default why does the driver have to send this information across the network to the database for every single query? Is there anyway to prevent it? We've looked at network traffic and this ALTER SESSION is adding 10 percent and it seems, at least to me, that it should be unecessary.
I've searched around but cannot find anything directly relating to this.
Thanks.Do you call connection.setTransactionIsolation()? That causes exactly that statement to be executed.
Do you use a connection pool? If yes: check if the pool calls setTransactionIsolation() - read the source, or ask the vendor, or decompile it (if that is legal in your part of the world.) If not using a pool: get one. -
How to close a session when user clicks Logout
In my jsp page i create a session for every user's name.
when particular user clicks logut without closing his personal page,
the others can access his page.
so, how to close a session when clicks logout link.?
similarly when user gets signin one system,he will not be sigin in other system.but how can we achieve this?
Thanks in AdvanceWhat is the name of the session variable that you are creating on login? When he clicks logout, set that session variable to null. Like session.setAttribute("userName",null); and check for non-null condition before proceeding with any functionality in your jsp's.
What is the second question? You want to prevent duplicate logins from different systems? You would have to maintain a static datastructure like a HashMap for instance. Everytime a user logs in, put an entry into the HashMap...like userMap.put("userName","userName"); If an entry already exists, throw a message saying that user already logged in from another machine... -
Is it risky to use statement : "alter session set events"
Hi guys,
I am extracting data from cxml documents.
I had to run the following code "EXECUTE IMMEDIATE ('alter session set events ''31156 trace name context forever, level 2'''); " to disable the DTD validation...b4 running any xml extract function on it.
Example:
CREATE OR REPLACE FUNCTION f_test (
p_cxml IN CLOB
RETURN BOOLEAN
AS
l_payload varchar2(100);
l_cXML sys.xmltype := sys.xmltype.createXML(p_cxml);
BEGIN
EXECUTE IMMEDIATE ('alter session set events ''31156 trace name context forever, level 2''');
SELECT EXTRACTVALUE(l_cXML,'/cXML/@payloadID')
INTO l_payload
FROM DUAL;
RETURN TRUE;
DBMS_OUTPUT.PUT_LINE (l_payload);
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.PUT_LINE (SQLCODE || ' - '||SQLERRM);
RETURN FALSE;
END;
The vlaue of the parameter p_cxml could be
p_cXML clob:=
'<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE cXML SYSTEM "http://xml.cXML.org/schemas/cXML/1.2.021/Fulfill.dtd">
<cXML payloadID="[email protected]"
timestamp="2000-10-12T18:39:09-08:00" xml:lang="en-US">
<Request deploymentMode="test">
<OrderRequest>
<OrderRequestHeader orderID="DO1234" orderDate="2000-10-12T18:41:29-08:00"
type="new">
<Total>
<Money currency="USD">187.60</Money>
</Total>
<ShipTo>
<Address>
<Name xml:lang="en">Acme</Name>
<PostalAddress name="default">
<DeliverTo>Joe Smith</DeliverTo>
<DeliverTo>Mailstop M-543</DeliverTo>
<Street>123 Anystreet</Street>
<City>Sunnyvale</City>
<State>CA</State>
<PostalCode>90489</PostalCode>
<Country isoCountryCode="US">United States
</Country>
</PostalAddress>
</Address>
</ShipTo>
</OrderRequestHeader>
</OrderRequest>
</Request>
</cXML>';
It is seems to be working.......................
MY QUESTION IS...
Is there any risk Involved to Using the
EXECUTE IMMEDIATE ('alter session set events ''31156 trace name context forever, level 2'''); statment.
Any Help will be greatly appreciated.
Thanks.Most "set events" are workarounds or needed for Oracle support to do some debugging. Using them is at your own risk, and probably not supported by Oracle if you get into trouble.
-
Date format with alter session -- very urgent !!!!
The default format of date is DD-MON-YY.
I like to change as DD/MM/YYYY. So I tried to do so by going
through my login in SQLPlus and wrote
ALTER SESSION
SET NLS_DATE_FORMAT = 'DD/MM/YYYY'.
The format got changed and there after every query displayed
date in dd/mm/yyyy format. But once I exit sqlplus and reenter
in sqlplus, the format goes away and the default date format i.e
dd-mon-yy comes in existence.
I want to know, how can i make my date format permanent and too
for all users.
nullhello Khan,
You can set this format in 2 ways, one is
local setting and the other one is on server setting.
Edit your c:\windows\oracle.ini (local setting)
or your init.ora (oracle server setting)
and add this script
SET NLS_DATE_FORMAT = 'DD/MM/YYYY'
note: if there's no nls_date_format in oracle.ini, the server
nls_date_format in init.ora will be the current setting
on your PC
Hope this will help
NEC PHIl.
Shamsad Khan (guest) wrote:
: The default format of date is DD-MON-YY.
: I like to change as DD/MM/YYYY. So I tried to do so by going
: through my login in SQLPlus and wrote
: ALTER SESSION
: SET NLS_DATE_FORMAT = 'DD/MM/YYYY'.
: The format got changed and there after every query displayed
: date in dd/mm/yyyy format. But once I exit sqlplus and reenter
: in sqlplus, the format goes away and the default date format
i.e
: dd-mon-yy comes in existence.
: I want to know, how can i make my date format permanent and
too
: for all users.
null
Maybe you are looking for
-
All of the software is installed and it worked without any problem. The problem appears to occur after the computer has gone into standby. The only way I can get anything to print is to turn it off the printer and then turn it back on again. The t
-
Error while installing iTunes 8.2.1 on Windows 7 [iTunes 8.0 works]
My anti-virus thought iTunes had a virus and "broke it." I went to uninstall it then re-install. No luck. I managed to get 8.0 installed, but it doesn't recognize my iPhone or iPod. Look at the image for the error: http://twitpic.com/c0dgs
-
Getting error message when updating to 2.1
Anyone else having a problem updating to 2.1? iTunes tells me 2.1 is available and then when I click download and install I get the error message "the requested resource was not found." lenn
-
Why header does not stretch all the way from left to right?
I am using Dreamweaver CS3. I am a newbie. I modified a dreamweaver two column template. Now I find that there is always a gap between the header and the left and right edge of the web page! I am enclosing the css stylesheet. Please tell me where
-
System prefs constantly asks to be shut down and reopened on certain system prefs so cannot access
System prefs constantly asks to be shut down and reopened on certain system prefs so cannot access. Any answers.