PLSQL, SQL*PLUS get current username?
Asked Answered
U

4

10

I know that the show user command return: USER is "SCOTT"

But is it possible in a sql query or in a plsql script to only get the username of the current user and store it in a variable?

Under answered 1/5, 2014 at 22:12 Comment(1)
select user from dualGyve
Y
13

The USER built-in function may be used.

DECLARE
  v VARCHAR2(30);
BEGIN
  v := USER;
END;
Yazzie answered 2/5, 2014 at 5:38 Comment(1)
Notice this calls STANDARD.USER(), which produces a PL/SQL to SQL context switch. Better use this approach instead.Jainism
M
5
SYS_CONTEXT( 'USERENV', 'CURRENT_USER' )
Marcomarconi answered 1/5, 2014 at 22:16 Comment(1)
Deprecated as of 10g, better to use 'SESSION_USER' instead: docs.oracle.com/cd/B19306_01/server.102/b14200/functions165.htmDisconnect
R
0
fnd_profile.value('USERNAME')
fnd_profile.value('USER_ID')
fnd_flobal.user_id

these can be used to get the user details

Rhiamon answered 9/4, 2019 at 10:32 Comment(3)
fnd_profile is not a standard Oracle package. Can you give a link to the Oracle manual?Gyve
refer this for more info linkRhiamon
That's Oracle E-Business Suite. That is something different than Oracle's database product. You can't use those functions in SQL or PL/SQL through SQL*PlusGyve
C
-1
  1. SQL> show user; USER is "SCOTT"

or

  1. SQL> select user from dual;

USER

SCOTT

Chazan answered 25/6 at 13:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.