Reputation:
i have a plsql script, which is not properly terminated:
create or replace package mypackage
... (no semicolon/forward slash at the end)
the script is executed with sqlplus (12.1) on windows powershell:
sqlplus user/pass@host @my_not_properly_ended_file.pks
i would expect sqlplus to terminate with exit code 1 and an error message, but instead it prompts for input.
how can i get an error message and exit code in this situation?
edit: solution should also work with dml statements that are not terminated with a semicolon.
Upvotes: 1
Views: 882
Reputation: 191570
You can use shell redirection instead of @
:
sqlplus user/pass@host < my_not_properly_ended_file.pks
This will also prevent it getting 'stuck' if the script doesn't end with an exit
command.
However, it won't return an error code to the shell in either case. As far as SQL*Plus is concerned you put the incomplete statement into its buffer but never attempted to execute it (as there was no slash); and as it didn't run, it didn't error. So setting whenever sqlerror
or whatever won't make any difference either.
Upvotes: 2