Oracle Alter用户无法使用PowerShell

时间:2019-11-18 18:50:28

标签: oracle powershell odac

我正在尝试使用PowerShell更改Oracle帐户。 .net DLL似乎不支持包含“更改用户”命令的Oracle SQL。我收到以下输出/错误:

Trying to connect to Database instance on NIMHDDEV...Success.
SELECT  ALL_USERS
SYS
Exception calling "ExecuteNonQuery" with "0" argument(s): "ORA-00922: missing or invalid option

下面是用于测试的PowerShell。

  • 有效的选择语句
  • 无效的alter语句
 [System.Reflection.Assembly]::LoadWithPartialName("System.Data.OracleClient")
$objOracleConnection = New-Object System.Data.OracleClient.OracleConnection 
$ds="Data Source=$ServerName; User ID=$login; Password=$password; Integrated Security=No" 
$objOracleConnection.ConnectionString = $ds
Write-Host "Trying to connect to Database instance on $ServerName..." -NoNewline
$objOracleConnection.Open()
Write-Host "Success."

$sql = "SELECT * FROM ALL_USERS" 
$cmd = New-Object System.Data.OracleClient.OracleCommand($sql, $objOracleConnection)
$cmd.ExecuteScalar()    


$sql = 'ALTER USER Account unlock'
$cmd = New-Object System.Data.OracleClient.OracleCommand($sql, $objOracleConnection)
$cmd.ExecuteNonQuery() 

0 个答案:

没有答案