Hello All,
I am getting an below oracle exception when i connect to oracle standby database to get archive sequence number. When i execute my powershell code normally, I am getting the result. But when i use try-catch-finally, i am getting below oracle exception when script makes a connection to standby database.
powershell code : $stdbyString = "Data Source=${datasource}; User ID=SYS; Password=*****; DBA Privilege=SYSDBA;" Try { $stdbyConnect = New-Object Oracle.ManagedDataAccess.Client.OracleConnection($stdbyString) $stdbyConnect.Open() $stdbyQuery = "select max(sequence#) from v`$log_history where first_time = (select max(first_time) from v`$log_history)" $stdbyCmd = new-Object Oracle.ManagedDataAccess.Client.OracleCommand($stdbyQuery, $stdbyConnect) $stdbyResult = $stdbyCmd.ExecuteReader() $stdbySeq = $( while ($stdbyResult.Read()) { $stdbyResult.GetValue(0) } ) write-host "Max Sequence of ${dbName} standby is :" $stdbySeq | ft } Catch [Oracle.ManagedDataAccess.Client.OracleException]{ $stdbySeq = $_.Exception.Message } finally { if ($stdbyConnect.State -eq 'Open') { $stdbyConnect.close() } }
Exception details :
ORA-06550: line 1, column 107:
PL/SQL: ORA-01219: database or pluggable database not open: queries allowed on fixed tables or views only
ORA-06550: line 1, column 68:
PL/SQL: SQL Statement ignored
ORA-06550: line 1, column 197:
PL/SQL: ORA-01219: database or pluggable database not open: queries allowed on fixed tables or views only
ORA-06550: line 1, column 162:
PL/SQL: SQL Statement ignored
ORA-06550: line 1, column 295:
PL/SQL: ORA-01219: database or pluggable database not open: queries allowed on fixed tables or views only
ORA-06550: line 1, column 248:
PL/SQL: SQL Statement ignored