Search code examples
sqlshellauthenticationsqlplus

sqlplus - command line select statement doesn't use login.sql settings


I have an sh script containing this:

sqlplus -S $JDBC_URL <<EOF
$1;
EOF

That works fine. However, it doesn't pick my formatting preferences from login.sql. Those settings work fine when I start SQL Plus in interactive mode.

Does anyone know how to make my script read login.sql? Is there some other file perhaps?


Solution

  • Depending on the version of sqlplus you are using and the operating system, you likely need to set and export the ORACLE_PATH (linux) or SQLPATH (windows) environment variable to include the directory that contains login.sql.

    I just found that past version used to look in the present-working-directory but that was not happening on the linux server I was working on. Setting SQLPATH did not work either because it is used in windows; setting ORACLE_PATH did work.

    Attribution for this information