Highlight warnings and errors
sqlplus rene/secretGarden@Ora19 `@script | foreach-object { $line = $_; $line = $line -replace '^(error|warning).*|^SP2-', "$([char]27)[38;5;9m$line$([char]27)[0m" ; $line }
Note: in the example above, the @
before the script name must be escaped with the back-tick (PowerShell's escape character).
Execute a single statement
The following example executes a single
SQL statement by
piping it into the SQL*Plus executable. The statement is followed by a new line (`n) and
exit
so that sqlplus returns to the shell again:
PS> "grant select on customer to sales;`nexit" | sqlplus [admin]@db