Monday, September 15, 2014

How to set Client Information in V$SESSION

We can set client information (USER ID) Using DBMS_APPLICATION_INFO package. If we set this client information it is easy to trace client id using CLIENT_INFO from V$SESSION data dictionary view.



C:\Users\rajib.pradhan>SQLPLUS /NOLOG

SQL*Plus: Release 11.2.0.1.0 Production on Mon Sep 15 18:26:30 2014

Copyright (c) 1982, 2010, Oracle.  All rights reserved.

SQL> CONN RND/rnd@ORCL
Connected.
SQL> SELECT CLIENT_INFO, SID, SERIAL# FROM V$SESSION
  2  WHERE USERNAME='RND';

CLIENT_INFO                                                             SID
---------------------------------------------------------------- ----------
   SERIAL#
----------
                                                                        132
         8


SQL> SET LINE 2000
SQL> SELECT CLIENT_INFO, SID, SERIAL# FROM V$SESSION
  2  WHERE USERNAME='RND';

CLIENT_INFO                                                             SID    SERIAL#
---------------------------------------------------------------- ---------- ----------
                                                                        132          8

SQL> begin
  2  DBMS_APPLICATION_INFO.SET_CLIENT_INFO ('RND_USER');
  3  end;
  4  /

PL/SQL procedure successfully completed.

SQL> SELECT CLIENT_INFO, SID, SERIAL# FROM V$SESSION
  2  WHERE USERNAME='RND';

CLIENT_INFO                                                             SID    SERIAL#
---------------------------------------------------------------- ---------- ----------
RND_USER                                                                132          8

SQL>

No comments:

Post a Comment