sql - How to check if the connection to the database was successful? -
sql - How to check if the connection to the database was successful? -
i need check if database connections successful or not. using command
sqlplus <username>/<password>@<sid>
if connection successful command returns variable flagged y/n or whatever. should done multiple servers , flags stored in file.
i not sure how conitnue?
linux platform
two_task=tns_alias sqlplus -s /nolog <<! whenever sqlerror exit 1; connect user/pass; select * dual; exit ! if [ $? = 0 ]; echo "success" else echo "failed" fi
windows platform
set local=tns_alias @( echo whenever sqlerror exit 1^; echo connect user/pass; echo select * dual^; echo exit^; ) > %temp%\run.sql sqlplus /nolog @%temp%\run.sql if "%errorlevel%"=="0" cls &echo success. if "%errorlevel%"=="1" cls &echo failed
sql oracle bash shell
Comments
Post a Comment