locked
Getting environment settings from Oracle RRS feed

  • Question

  • Hi,

    I'm able to connect to Oracle and run standard Select queries but I want to be able to return the environment parameters, when logging into the DB I'd run show parameter to get these but via my script i'm getting ORA-00900 invalid SQL statement.

    Is anyone able to help or point me in the right direction?

    So far I have 

    Add-Type -AssemblyName System.Data.OracleClient

    $user = "user"
    $pass = "password"
    $port = "1521"
    $query = "select * from sometable"
    $hostname = "hostname"

    $con = New-Object Oracle.ManagedDataAccess.Client.OracleConnection("User Id=" + $user +";Password=" +$pass +";Data Source="+ $hostname + "/" + $hostname)
    $cmd=$con.CreateCommand()
    $cmd.CommandText=$query
    $con.Open()
    $rdr=$cmd.ExecuteReader()
    if ($rdr.Read()) 
    {
       $rdr.GetString(0)
       $output = $hostname +" - " + $rdr.GetString(0)
       write-host $output
    }
    $con.Close()

    Cheers,

    Gareth

    Monday, November 27, 2017 2:26 PM

Answers

  • That command only works in the Oracle console.  To find out how to use SQL to get the same thing post in Oracle forum.

    \_(ツ)_/

    • Marked as answer by LlewBach78 Monday, November 27, 2017 3:28 PM
    Monday, November 27, 2017 3:15 PM