1

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

6
  • Did you already check this? tekstream.com/resource-center/… Commented Jul 24, 2020 at 7:09
  • There is one more answer of this, stackoverflow.com/questions/8940471/… Commented Jul 24, 2020 at 7: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. Commented Jul 24, 2020 at 7:17
  • Remove Grant and run it. GRANT SELECT ON table TO user1; SELECT ON table TO user2; Commented Jul 24, 2020 at 7: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; Commented Jul 24, 2020 at 7:30

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.