0

I have a SQL file and I'm trying to execute queries in it via PowerShell. But even I can execute one query, I can not when adding that file multiple queries like below.

GRANT SELECT ON table TO user1;
GRANT SELECT ON table TO user2;
Exception calling "ExecuteReader" with "0" argument(s): "ORA-00933: SQL komutu tam doğru olarak sona ermedi"   
At line:23 char:5   
$reader = $command.ExecuteReader()
+ CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : OracleException
$query=Get-Content C:\Users\asdg.sql | Out-String
write-host $query


$command.CommandText = $query
$reader = $command.ExecuteReader()

while ($reader.Read()) {
    $reader.GetString(0)
    }

English Error:

SQL command did not end properly

Utkarsh Dubey
  • 703
  • 11
  • 31
Rogue
  • 1
  • 2
  • Did you already check this? https://www.tekstream.com/resource-center/ora-00933-sql-command-not-properly-ended/ – Utkarsh Dubey Jul 24 '20 at 07:09
  • There is one more answer of this, https://stackoverflow.com/questions/8940471/sql-error-ora-00933-sql-command-not-properly-ended – Utkarsh Dubey Jul 24 '20 at 07:13
  • yeah but removing ";" doesnt work neither. when there is one query like GRANT SELECT ON table TO user1 is fine but when there are two or more dont work. – Rogue Jul 24 '20 at 07:17
  • Remove Grant and run it. `GRANT SELECT ON table TO user1; SELECT ON table TO user2;` – Utkarsh Dubey Jul 24 '20 at 07:26
  • sorry, thats not work either.. there arent no grants only but there should be queries like below. ALTER TRIGGER x DISABLE; UPDATE table SET column = 1 WHERE t IN ('y'); COMMIT; – Rogue Jul 24 '20 at 07:30
  • Try this, `ALTER TRIGGER x DISABLE; UPDATE table SET column = 1 WHERE t = 'y'; COMMIT;` – Utkarsh Dubey Jul 24 '20 at 08:01

0 Answers0