15 March 2016

Execute stored procedure in oracle database from powershell



 $connectionString =“User Id=username;Password=password;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=appname.domain.intra)(PORT=1523)))(CONNECT_DATA=(SID=sid)))”;

$oracleConnection = new-object System.Data.OracleClient.OracleConnection($connectionString);
$ProcName = "procedure_name";
$oracleConnection.Open();
$cmd = new-object System.Data.OracleClient.OracleCommand;
$cmd.Connection = $oracleConnection;
$cmd.CommandText = $ProcName;
$cmd.CommandType = [System.Data.CommandType]::StoredProcedure;
$cmd.ExecuteNonQuery();
$oracleConnection.Close();

1 comment:

  1. $oracleConnection = new-object what will be new-object here & will this be same [System.Data.CommandType]?

    ReplyDelete