Skip to content

Commit

Permalink
Bugfix inst_id for Oracle 11.2
Browse files Browse the repository at this point in the history
  • Loading branch information
rammpeter committed Aug 22, 2023
1 parent 2319073 commit 79a1f36
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
9 changes: 4 additions & 5 deletions app/controllers/env_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def start_page
SYSDATE, TO_CHAR(SYSTIMESTAMP, 'TZH:TZM') Sys_Offset,
CURRENT_DATE, TO_CHAR(CURRENT_TIMESTAMP, 'TZH:TZM') Current_Offset
FROM v$Database" # Zugriff ueber Hash, da die Spalte nur in Oracle-Version > 9 existiert

@instance_number = sql_select_one "SELECT Instance_Number FROM v$Instance"

client_info = sql_select_first_row "SELECT sys_context('USERENV', 'NLS_DATE_LANGUAGE') || '_' || sys_context('USERENV', 'NLS_TERRITORY') NLS_Lang FROM DUAL"

Expand Down Expand Up @@ -182,11 +182,11 @@ def start_page
UNION ALL
SELECT Inst_ID, Parameter, Value FROM gv$NLS_Parameters WHERE Con_ID = SYS_CONTEXT('USERENV', 'CON_ID')"
else
"SELECT Inst_ID, Parameter, Value FROM NLS_Database_Parameters"
"SELECT #{@instance_number} Inst_ID, Parameter, Value FROM NLS_Database_Parameters"
end
@instance_data = sql_select_all "WITH System_Parameter AS (#{system_parameter_sql}),
NLS_Parameters AS (#{nls_parameters_sql})
SELECT /* NO_CDB_TRANSFORMATION */ gi.*, i.Instance_Number Instance_Connected,
SELECT /* NO_CDB_TRANSFORMATION */ gi.*,
(SELECT n.Value FROM NLS_Parameters n WHERE n.Inst_ID = gi.Inst_ID AND n.Parameter='NLS_CHARACTERSET') NLS_CharacterSet,
(SELECT n.Value FROM NLS_Parameters n WHERE n.Inst_ID = gi.Inst_ID AND n.Parameter='NLS_NCHAR_CHARACTERSET') NLS_NChar_CharacterSet,
(SELECT p.Value FROM System_Parameter p WHERE p.Inst_ID = gi.Inst_ID AND LOWER(p.Name) = 'cpu_count') CPU_Count,
Expand All @@ -201,7 +201,6 @@ def start_page
#{", CDB" if get_db_version >= '12.1'}
FROM GV$Instance gi
CROSS JOIN v$Database d
LEFT OUTER JOIN v$Instance i ON i.Instance_Number = gi.Instance_Number
LEFT OUTER JOIN (SELECT /*+ NO_MERGE */ Inst_ID,
MAX(DECODE(Stat_Name, 'NUM_CPUS', Comments||': '||Value)) Num_CPUs,
MAX(DECODE(Stat_Name, 'NUM_CPU_CORES', Comments||': '||Value)) Num_CPU_Cores,
Expand All @@ -215,7 +214,7 @@ def start_page
LEFT OUTER JOIN (SELECT /*+ NO_MERGE */ Inst_ID, COUNT(*) Service_Count FROM gv$Services GROUP BY Inst_ID) srv ON srv.Inst_ID = gi.Inst_ID
"
@instance_data.each do |i|
if i.instance_connected
if i.inst_id == @instance_number
@instance_name = i.instance_name
@host_name = i.host_name
set_current_database(get_current_database.merge({:cdb => true})) if get_db_version >= '12.1' && i.cdb == 'YES' # Merken ob DB eine CDP/PDB ist
Expand Down
2 changes: 1 addition & 1 deletion app/views/env/_start_page.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
column_options =
[
{:caption=>'DBID', :data=>proc{|rec| rec.dbid }, :title=>"Unique identifier for this database", data_title: proc{|rec| "%t\nDB version = #{rec.version}"} },
{:caption=>"I.", :data=>proc{|rec| "#{rec.instance_number}#{" (*)" if rec.instance_connected && @instance_data.length >1}" }, :title=>"Instance number, (*) for connecting instance", data_title: proc{|rec| "%t\nDB version = #{rec.version}"} },
{:caption=>"I.", :data=>proc{|rec| "#{rec.instance_number}#{" (*)" if rec.instance_number == @instance_number && @instance_data.length >1}" }, :title=>"Instance number, (*) for connecting instance", data_title: proc{|rec| "%t\nDB version = #{rec.version}"} },
{:caption=>'Version', :data=>proc{|rec| rec.version >= '19' ? rec.version_full : rec.version }, :title=>"Instance version / full version" },
{:caption=>"Name", :data=>proc{|rec| rec.instance_name }, :title=>"Instance name", data_title: proc{|rec| "%t\nDB version = #{rec.version}"} },
{:caption=>"Host name", :data=>proc{|rec| rec.host_name }, :title=>"Last startup time of instance"},
Expand Down

0 comments on commit 79a1f36

Please sign in to comment.