i have a problem with sqlplus on windows batch. I have SQLPLUS 10.2
i'm trying to connect to a database through a windows script.cmd
script.cmd only launches : sqlplus test/Test@mydatabase @script.sql
The problem is when the database is not available, the sqlplus says
ERROR:
ORA-12541: TNS:no listener
Enter user-name :
and waits for input .. and blocks the .cmd
How can i adapt the script to stop immediately when the database is not avaliable or just to avoid waiting for user prompts ?
Thanks
To exit SQL*Plus command-line, enter EXIT. To exit the Windows GUI, enter EXIT or select Exit from the File menu.
You can end a SQL command in one of three ways: with a semicolon (;) with a slash (/) on a line by itself. with a blank line.
The SET DEFINE command changes the prefix character used to mark substitution variables. You can use SET DEFINE to turn variable substitution off.
You can do sqlplus -l test/Test@mydatabase @script.sql
; the -l
flag means it will only try to connect once, and if it fails for any reason will exit instead of prompting. Look at the output of sqlplus -?
, or see the documentation.
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