Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

sqlplus login script

xxsawerMay 18 2020 — edited May 19 2020

Hi all,

I am running sqlplus from a shell script like following:

sqlplus -L -S /nolog @script.sql

script.sql starts with CONNECT command which connects me to a DB schema. Now there is a login script login.sql which contains an ALTER SESSION statement. As per documentation, this login script is executed:

Prior to the first prompt when /NOLOG is specified on the command line and no connection is made.

That means the login script is executed before connection to DB schema is made and the ALTER SESSION statement generates the "SP2-0640: Not connected" error message

It is not a big deal, but sill I am wondering whether there is a way how to either avoid executing the login script when /NOLOG parameter is specified or how to make the ALTER SESSION statement within the script dependent on presense of database session?

Thanks in advance for your hints.

This post has been answered by EdStevens on May 18 2020
Jump to Answer
Comments
Post Details
Added on May 18 2020
11 comments
1,757 views