Skip to content
March 30, 2018 / doganay

HOW TO DISPLAY OS VARIABLE in ORACLE


12c

select sys_context('USERENV','ORACLE_HOME') as OS_VAR_OH from dual


11g

create or replace function print_os_var (os_var_name in varchar2) return clob
as
v_var_os clob;
begin
dbms_system.get_env(os_var_name, v_var_os);
return v_var_os;
end;
/

14:16:27 SYS@DBAT1124> select print_os_var('ORACLE_HOME') from dual;

PRINT_OS_VAR
------------
/u01/app/oracle/product/11204

You may get any parameter which has set before you startup the instance. For example:

$ export AAA="abc"

$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Fri Mar 30 14:52:15 2018

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

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning option

SQL> shu immediate

Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.

Total System Global Area 3140026368 bytes
Fixed Size 2257352 bytes
Variable Size 2046823992 bytes
Database Buffers 1073741824 bytes
Redo Buffers 17203200 bytes
Database mounted.
Database opened.

14:54:27 SYS@DBAT1124> select print_os_var('AAA') from dual;

PRINT_OS_VAR
------------
abc

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: