Confuse on alter session

Hi,
I was trying to enable the sql_trace or the events for me to start the tracing utility. I got this following output:
rrkr@ORA10G> alter session set timed_statistics=true;
Session altered.
rrkr@ORA10G> alter session set events '10046 trace name context forever, level 12';
ERROR:
ORA-01031: insufficient privileges
rrkr@ORA10G> alter session set sql_trace=true;
alter session set sql_trace=true
ERROR at line 1:
ORA-01031: insufficient privileges
-- at another session
rrkr_dba@ORA10G> grant alter session to rrkr;
Grant succeeded.
--- back to the first session
rrkr@ORA10G> alter session set sql_trace=true;
Session altered.
rrkr@ORA10G>As you can see I got to execute the timed_statistics, but not the sql_trace. How did that happen if I really dont have the alter session priviledge? Thank you.
Regards,
Rhani

It seems Oracle first checks whether it has to change anything.
It doesn't need to change anything, the statements succeeds, without having checked whether the session has privilege to change the session.
In other cases, you had to change something, privileges were checked, and you got an error.
Privilege checking should occur first.
The internal algorithm is fundamentally flawed.
Sybrand Bakker
Senior Oracle DBA

Similar Messages

  • Is it possible to use "english hijrah" on-the-fly without ALTER SESSION?

    SQL> alter session set nls_calendar='english hijrah';
    Session altered.
    SQL> select '29-02-1435', TO_DATE('29-02-1435', 'DD-MM-RRRR') from dual;
    '29-02-1435' TO_DATE('29-02-1435','DD-MM-RRRR')
    29-02-1435 29 Safar 1435
    Hi, the above shows that an input date of '29-02-1435' can be validated as a correct Hijrah date.
    However, is it possible to do such a TO_DATE(), or TO_CHAR() conversion without the overhead of an 'ALTER SESSION' at the start ?
    From within a Gregorian session I tried a few things like below, but they didn't work and give ORA-01756: quoted string not properly terminated
    select TO_CHAR('29-02-1435', 'nls_calendar="English Hijrah"', 'nls_date_format="DD-MM-RRRR")
    from dual;
    All we're needing to do is validate the date as valid Hijrah - no further processing is done.
    Many thanks for any help. Mark

    Sorry - I had been confusing single and double quotes.
    The following shows that it's a valid Arabic date
    SQL> select '29-02-1435', TO_DATE('29-02-1435', 'DD-MM-RRRR', 'nls_calendar=''English Hijrah''')
    2 from dual;
    '29-02-1435' TO_DATE('29-02-
    29-02-1435 02-JAN-14
    and for example if you put a crazy month, it complains
    SQL> select '29-02-1435', TO_DATE('29-92-1435', 'DD-MM-RRRR', 'nls_calendar=''English Hijrah''')
    2 from dual;
    select '29-02-1435', TO_DATE('29-92-1435', 'DD-MM-RRRR', 'nls_calendar=''English Hijrah''')
    ERROR at line 1:
    ORA-01843: not a valid month

  • 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 PM

    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). 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

  • Create view and alter Session gets 0RA-01031

    I can't create a view after using ALTER SESSION set current_schema without using an explicit schema. I get ORA-01031. Is this a known bug? Here are the details:
    1. Log on as SYSTEM
    2. ALTER SESSION set current_schema=FRED;
    3. CREATE VIEW vFoo as select * from Foo;     -- ORA-01031: insufficient privileges
    4. CREATE VIEW FRED.vFoo as select * from Foo;     -- this works!
    I've read where some privileges need to be granted directly. In fact, if Fred grants select privilege on Foo to SYSTEM, the statement in #3 above works. However, something doesn't seem right because why does #4 succeed without the GRANT?
    In case you're wondering why I don't just use #4 above, which does work, it's because I've got a script that will be run by customers to create tables, views, etc. in an arbitrary schema and the schema is associated with a user with limited permissions. Hence, the use of the ALTER SESSION.

    See, You looged as SYSTEM (Scheme = SYSTEM)
    Now you alter your session to another schema FRED.
    Now if you want to access SCHEMA of FRED, You need to connect first.
    SQL > connect user/password@host
    Then
    SQL > CREATE VIEW vFoo as select * from Foo;
    View created.

  • Alter session set NLS_DATE_FORMAT and to_date not working

    Hey folks,
    for the sake of simplicity let's assume i want to get the current system time from the table dual in a certain format, e.g. 'YY.MM.DD'.
    Currently the query
    select sysdate from dual;
    yields:
    07-JAN-08
    The desired output should look like this:
    08.01.07
    So, according to the manual, i tried the following:
    alter session set NLS_DATE_FORMAT = 'yy.mm.dd';
    No effect, date is still displayed as
    07-JAN-08
    Even the following query:
    select TO_DATE (sysdate, 'yy.mm.dd') from dual;
    yields
    07-JAN-08
    What am i doing wrong here?
    Additional information:
    -> DB is Oracle 9
    -> I am using the Oracle SQL Developer under Ubuntu Gutsy
    -> No, i did not forget to commit my commands....:-)
    Any ideas?

    select TO_CHAR (sysdate, 'yy.mm.dd') from dual;However the alter session command should work:
    SQL*Plus: Release 9.2.0.2.0 - Production on Mon Jan 7 14:32:26 2008
    Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
    Connected to:
    Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.8.0 - Production
    SQL> alter session set NLS_DATE_FORMAT = 'yy.mm.dd';
    Session altered.
    SQL> select sysdate from dual;
    SYSDATE
    08.01.07
    SQL> Note: There is nothing to commit here. Only selects, no DML.
    Message was edited by:
    Sven W.

  • 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 PM

    Hi:
    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).

  • Using ALTER SESSION inside a stored procedure.... not a good idea?

    Hi,
    I have two stored procedures, both of which are used to query a database to find a particular book, based on ISBN. One sproc searches our main product catalogue and the other searches our suppliers feed catalogues. The stored procedures are called from a C# application via a search tool and the user is able to search on either our catalogue or our suppliers. The appropriate procedure is called based on the users choices.
    However, the following behaviour is observed
    I search for an ISBN (is a varchar2 field, as isbn's may contain an X if the checksum digit equates to 10) on a feed, so uses the FEED SPROC. The book is found and returned to the app in about 0.5 seconds. I can repeat this as often as i like on different books etc. always works fine.
    I then do the same search but against our own catalogue, so uses our CATALOGUE SPROC. Again the book is found quickly, and the search can be repeated with the same results.
    If i then go back and run our FEED SPROC then the search time increases to about 3 minutes !
    Both the feed and our catalogue is in the same database, although different schema's the connections will be pooled through our app server.
    I can repliacte this every single time. I think i have narrowed doen the cause of this behaviour to a few lines of code in our CATALOGUE SPROC:
    -- store values
    select value into v_vch_NLS_COMP from nls_session_parameters nsp where nsp.parameter = 'NLS_COMP';
    select value into v_vch_NLS_SORT from nls_session_parameters nsp where nsp.parameter = 'NLS_SORT';
    -- Ensure case insensitivity throughout
    EXECUTE IMMEDIATE 'ALTER SESSION SET NLS_COMP = LINGUISTIC';
    EXECUTE IMMEDIATE 'ALTER SESSION SET NLS_SORT = BINARY_CI';
    do other stuff
    -- restore session variables
    EXECUTE IMMEDIATE 'ALTER SESSION SET NLS_COMP = ' || v_vch_NLS_COMP;
    EXECUTE IMMEDIATE 'ALTER SESSION SET NLS_SORT = ' || v_vch_NLS_SORT;
    If i remove this code then all is well, so i am assuming that using ALTER SESSION inside a stored procedure is the cause of the problem as it would be changing the execution plan of the FEEDS SPROC in some manner? Any ideas? I know i can just rewrite the sproc to avoid using this coding, but wanted to understand if i am doing something wrong by using ALTER SESSION in this manner?
    Any pointers would be appreciated.
    John Thompson
    Software Architect,
    play.com
    Edited by: user7186902 on 27-May-2009 03:51

    Hello (and welcome),
    It may be a case of having to create a linguistic index to facilitate the queries once you set these session level parameters, i.e..,
    CREATE INDEX idx_01 ON tab ((NLSSORT(col1, 'NLS_SORT=BINARY_CI'))It would appear that the setting of those parameters is invalidating index searching on the current indexes.

  • 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,
    Maxime

    Thank 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

  • "alter session set sql_trace true"  in my pakage is not working

    Hi
    I have a package with some procedures..in one of my procedure which is executed in the first step i run the :
    execute immediate 'alter session set sql_trace true';
    this command is executed in debug mode and generate trace file(GOOD) but in running mode i haven't trcce file.
    what is wrong in my code ?

    http://download.oracle.com/docs/cd/E11882_01/server.112/e26088/statements_2013.htm#SQLRF00901 says parameter_name = parameter_value
    Regards
    Etbin

  • 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.

  • Alter session is not wofking

    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

  • 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,
    Siva

    Sounds 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.

  • How to use 'alter session...' in apex

    Hello everyone, in my APEX program, I need to alter the parameter nls_date_language with 'alter session set nls_date_language = american'.
    I execute the statement in SQL Commands of APEX, but it doesn't seem it works. how can I change the parameter--nls_date_language in APEX?
    Any answer is appreciated.

    Hi,
    This might help
    http://download.oracle.com/docs/cd/E14373_01/appdev.32/e11838/bldr.htm#BABGGAJE
    >
    Application Date Format
    Determines the date format to be used in the application.
    This date format is used to alter the NLS_DATE_FORMAT database session setting before showing or submitting any page in the application. This value can be a literal string containing a valid Oracle date format mask or an item reference using substitution syntax. If no value is specified, the default date format is derived from the database session at runtime.
    >
    Br,Jari

  • 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,
    Rob

    Please 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

  • ALTER SESSION in sql script produces strange results

    Why would "alter session set NLS_DATE_FORMAT" interfere with the operation of a sql script?
    First, the script without the ALTER SESSION:
    SQL> !cat doit1.sql
    --alter session set NLS_DATE_FORMAT = "DD-MON-YYYY"
    set pagesize 99
    set trimspool on
    col BIRTH_MONTH for a11
    break on BIRTH_MONTH skip 1
    spo doit.txt
    prompt My Membership
    set feedback off heading off
    select 'As of ' || sysdate from dual;
    set heading on
    select count(*) from dual;
    spool offAnd its execution:
    SQL> @doit1
    My Membership
    As of 14-JAN-10
      COUNT(*)
    1All's well with the world. Now let's throw in the ALTER SESSION:
    SQL> !cat doit2.sql
    alter session set NLS_DATE_FORMAT = "DD-MON-YYYY"
    set pagesize 99
    set trimspool on
    col BIRTH_MONTH for a11
    break on BIRTH_MONTH skip 1
    spo doit.txt
    prompt My Membership
    set feedback off heading off
    select 'As of ' || sysdate from dual;
    set heading on
    select count(*) from dual;
    spool offAnd its execution
    SQL> @doit2
    set pagesize 99
    ERROR at line 2:
    ORA-00922: missing or invalid option
      COUNT(*)
    1
    not spooling currently
    SQL> Doesn't like the SET commands (I've played around with serveral, it doesn't like any of them) and ignores the opening SPOOL command
    I first noticed this with a 10.2.0.1 client (windows) connected to a 10.2.0.4 database (HP-UX). Confirmed on my laptop VM lab, 10.2.0.4 under OEL5, client and db on same VM.

    Chris Poole wrote:
    You're just missing the trailing ';' at the end of the alter session line. Add this, it all works.DOH! (in my best Homer Simpson imitation!)

Maybe you are looking for

  • Installation fails on new Macbook Pro

    I am trying to install CS3 on a new Macbook Pro Retina 13" with Mavericks. All of the CS3 apps except Photoshop installed correctly. Photoshop fails and when I try to launch it returns a message that it cannot be initialized because the disk is not a

  • How to connect a second monitor/TV to HP ENVY Beats All-In-One

    Hi, I was wondering if anyone could tell me if it is even possible to connect a second monitor to the HP ENVY Beats All-In-One Desktop PC, because I'm trying to connect my TV as the second monitor through HDMI and I've tried everything that I could,

  • Embed website in Web Dynpro View

    Hi all, I am trying to embed a website in a Web Dynpro View. I am not sure about it how to get this. I have created a ViewContainerUIElement on the view and the website should be placed in this element. My code for creating the website looks like fol

  • Please help me. Cant located the Path of java.exe ???

    I have Windows 7 64bit OS. I download all softwares in 64 bit version.I just download Oracle sql developer 4.0 (4.0.0.13.80) and jdk 7 u45 with netbeans 7.4 and i also download jre 7, all software are successfully installed on my system. but when i o

  • Convert payslip to PDF format  , for e-mailing to employees

    HI with respect to my previous post 'Salary slip delivery thru email' I have been able to send the email out in the html format. I want the employee to recieve the mail in the PDF format. I would like your assistance on this. Here is the code. tables