How can the TNS connect identifier passed to SQL*Plus be accessed from the run script for reconnecting? I wonder how the TNS identifier can be used within a SQL script. In this example

$ sqlplus MY_USER/pswd@TNSID @script.sql par1 par2


I'd like to get TNSID as a string in order to use it from script.sql but I have no idea where to find it.

The goal is to reconnect as a different user on the same instance.
Sure, pass it as a parameter too.

sqlplus MY_USER/pswd@TNSID @script.sql TNSID par2 par3


Then you can use the below in the script:

connect MY_USER2/pswd@&amp;1