How to Get the Program Name in 11g version [message #690160] |
Fri, 08 November 2024 13:15 |
wtolentino
Messages: 421 Registered: March 2005
|
Senior Member |
|
|
In 12c and later version of the oracle database I can use this built-in function to get the program name:
sys_context('USERENV','CLIENT_PROGRAM_NAME')
In 11g what is the similar parameters or function that I can use? Please help.
Thank you,
Warren
|
|
|
|
|
|
|
Re: How to Get the Program Name in 11g version [message #690165 is a reply to message #690164] |
Sat, 09 November 2024 00:49 |
|
Michel Cadot
Messages: 68729 Registered: March 2007 Location: Saint-Maur, France, https...
|
Senior Member Account Moderator |
|
|
The problem is not with V$MYSTAT (or SYS.V_$MYSTAT) which is granted SELECT to PUBLIC (default settings in 11g) but with V$SESSION:
SQL> select grantee from dba_tab_privs where owner='SYS' and table_name='V_$MYSTAT' and privilege='SELECT' order by 1;
GRANTEE
------------------------------
APEX_030200
PLUSTRACE
PUBLIC
SELECT_CATALOG_ROLE
4 rows selected.
SQL> select grantee from dba_tab_privs where owner='SYS' and table_name='V_$SESSION' and privilege='SELECT' order by 1;
GRANTEE
------------------------------
APEX_030200
APPQOSSYS
CTXSYS
ORACLE_OCM
PERFSTAT
SELECT_CATALOG_ROLE
6 rows selected.
SQL> @v
Oracle version: 11.2.0.4.181016 EE - JVM v1.6.0_43 - timezone files v11
[Updated on: Sat, 09 November 2024 00:49] Report message to a moderator
|
|
|
Re: How to Get the Program Name in 11g version [message #690166 is a reply to message #690165] |
Sat, 09 November 2024 06:06 |
Solomon Yakobson
Messages: 3303 Registered: January 2010 Location: Connecticut, USA
|
Senior Member |
|
|
We can use own context:
create or replace
context ctx
using ctx_pkg
/
create or replace
package ctx_pkg
is
procedure set_program;
end;
/
create or replace
package body ctx_pkg
is
procedure set_program
is
v_program varchar2(64);
begin
select program
into v_program
from v$session
where sid = sys_context('userenv','sid');
dbms_session.set_context('ctx','program',v_program);
end;
end;
/
create or replace
trigger after_login_trg
after logon
on database
begin
ctx_pkg.set_program;
end;
/
Now:
SQL> connect u1/u1@orcl11
Connected.
SQL> select banner from v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
PL/SQL Release 11.2.0.1.0 - Production
CORE 11.2.0.1.0 Production
TNS for 32-bit Windows: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
SQL> select sys_context('ctx','program') program from dual;
PROGRAM
--------------------------------------------------------------------------------
sqlplus.exe
SQL>
SY.
|
|
|
|