3

I have a batch script that invokes PLSQL with connection details, which works fine but I still have to explicitly SET DEFINE OFF when I connect. I would like to enhance my simple batch script to pass the SET DEFINE OFF command to SQLPLUS so that once I am connected, I will no longer have to issue that command manually.

echo set define off | sqlplus user/pwd@tnsname

This does not work. I am logged in, and logged out again immediately (output follows):


SQL*Plus: Release 10.2.0.3.0 - Production on Mon Jun 15 16:43:17 2009
Copyright (c) 1982, 2006, Oracle. All Rights Reserved.

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> SQL> Disconnected from Oracle Database 10g Enterprise Edition Release 10.2. 0.4.0 - Production With the Partitioning, OLAP, Data Mining and Real Application Testing options

D:>

Peter Perháč
  • 20,434
  • 21
  • 120
  • 152

2 Answers2

5

Or in a file called login.sql in your current directory.

Todd Pierce
  • 806
  • 5
  • 8
  • There are some restrictions on `login.sql` since Oracle 12.2. See https://stackoverflow.com/a/65238388/2312935 – Httqm Dec 10 '20 at 16:26
2

Put SET DEFINE OFF either to the script itself or to glogin.sql (found in $ORACLE_HOME/sqlplus)

Quassnoi
  • 413,100
  • 91
  • 616
  • 614
  • Wow, I just learned a new thing - about that glogin.sql file. I would never have looked in. However, I would rather not have SET DEFINE OFF for EVERY time I connect to ANY instance. Just from that batch script. What do you mean by Put SET DEFINE OFF either to the script itself? How? That's just what I am after... – Peter Perháč Jun 15 '09 at 15:57
  • @MasterPeter: just add a line saying SET DEFINE OFF to the beginning of the script :) – Quassnoi Jun 15 '09 at 16:02
  • The glogin.sql file (found in $ORACLE_HOME/sqlplus) impacts every user that uses the software in the defined ORACLE_HOME. "g" for "global". Some users of the software might be adversely impacted by a "global" change. – Beege Nov 29 '16 at 16:21