On an Oracle database server, I have been able to schedule a nightly job that runs oracle scripts initiated from a powershell script which has this line:
sqlplus accountID/password @C:\scripts\run_scripts.sql
Now I need to achieve the same on another windows machine where the only thing of Oracle is the SQLcl client. I am able to invoke the initial_script.sql SQL script, but only interactively so far through three steps:
PS C:\sql_scripts> sql /nolog
SQL> connect id_maint/[email protected]:1521/sid
Connected.
SQL> @initial_script.sql
What I need is to have the oracle initial_script.sql script started from powershell. I have two hurdles.
PS> sql /nolog command at the powershell command prompt, and then run the SQL> connect id_maint/[email protected]:1521/sid command at the SQL> prompt.SQL> connect id_maint/[email protected]:1521/sid works fine. But I need to invoke the oracle script initial_script.sql at the same time. However,SQL> connect id_maint/[email protected]:1521/sid @C:\sql_scripts\initial_script.sql
incurs an error.
So what I am seeking is to get three things done (get the SQL> prompt -> connect to the remote database -> invoke the oracle script), all initiated by a power script at the PS> prompt.
Appreciated it very much if someone can help me out.
SQLcl is 99% compatible with SQLPlus so for almost any sqlplus command you should be able to just use sql.
Launch the script using your existing sqlplus command but using sql instead
sql id_maint/[email protected]:1521/sid @C:\sql_scripts\initial_script.sql
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With