Print Thread
Login.sql and AfterConnect.sql
#56351 04/14/17 03:03 PM
Joined: Apr 2008
Posts: 3
Brown University
Member
OP Offline
Member
Joined: Apr 2008
Posts: 3
Brown University
Hi Marco,

Great job on PL/SQL Developer 12! Lots of nice enhancements, that have got me exploring all the other features I ignored, such as the Command Window. I like it enough that I want to try using this as a replacement for my trusted SQL*Plus.

In putting the Command Window into production, I've struggled with the SQL Prompt setting. Since I manage multiple databases, it is very important to me to identify the User and DB with each prompt. I discovered that that my old prompt logic did not work:

SET TERMOUT OFF
COLUMN RTN_CHAR NEW_VALUE RTN_CHR
SELECT ''||CHR(10)||'' RTN_CHAR FROM DUAL;
COLUMN SQL_PRMPT NEW_VALUE SQL_PRMPT
SELECT 'SQL> ' SQL_PRMPT FROM DUAL;
COLUMN CONNECT_ID NEW_VALUE CONNECT_ID
SELECT UPPER('_CONNECT_IDENTIFIER') CONNECT_ID FROM DUAL;
set sqlprompt "_USER@&&CONNECT_ID &&RTN_CHR&&SQL_PRMPT"
SET TERMOUT ON


I was hoping to see

ADMIN@MYSCHEMA
SQL>


Instead, the variables were treated like literals and the resulting prompt was

_USER@&&CONNECT_ID &&RTN_CHR&&SQL_PRMPT>

Fortunately, I discovered this PSD syntax in another thread:

set sqlprompt [user]@[db]

But when I put it into AfterConnect.sql, it still did not work. I even tried adding various useful startup queries like

SELECT COUNT(*) FROM DAILY_ERROR_LOG;

I noticed that when I ran the Command Window, a little notification appeared at the bottom indicating that "login.sql" had executed. I use login.sql in my Oracle SQL*Plus configuration, and I couldn't understand how PSD was finding it, or how I could change it.

After an hour or so of debugging and reviewing documentation, I realized that Command Window uses it's own login.sql file.

So, my question:

What is the difference between login.sql and AfterConnect.sql, and how are they to be used? Also, what other variables are available? Can Command Window handle breaks and computes?

A document on this would be nice. smile



Re: Login.sql and AfterConnect.sql
Scott Lloyd #56353 04/17/17 07:20 AM
Joined: Aug 1999
Posts: 22,220
Member
Offline
Member
Joined: Aug 1999
Posts: 22,220
When searching the Login.sql file the precedence is as follows:

1. The current directory (by default the installation directory)
2. The command file directory from the preferences
3. The directory set by the SQLPATH environment variable
4. The directory set by the ORACLE_PATH environment variable

The login.sql file is executed when a Command Window opens. It can contain SQL commands, PL/SQL Blocks, but also Command Window commands such as SET PROMPT.

The AfterConnect.sql file is executed for all sessions of all window types. It can only contain SQL commands and PL/SQL Blocks.


Marco Kalter
Allround Automations
Re: Login.sql and AfterConnect.sql
Marco Kalter #56354 04/17/17 04:43 PM
Joined: Sep 2009
Posts: 165
California
J
Member
Offline
Member
J
Joined: Sep 2009
Posts: 165
California
I've never gotten this to work.
My command file directory is empty in preferences.
I have SQLPATH set in my environment variable.

My login.sql scripts works just fine for sqlplus on my computer.

Re: Login.sql and AfterConnect.sql
Marco Kalter #58252 08/21/18 11:45 PM
Joined: Dec 2002
Posts: 43
Phoenix, Arizona USA
Member
Offline
Member
Joined: Dec 2002
Posts: 43
Phoenix, Arizona USA
This information should be in the online documentation user guide.


Kate Johnson

Moderated by  support 

Link Copied to Clipboard
Powered by UBB.threads™ PHP Forum Software 7.7.4
(Release build 20200307)
Responsive Width:

PHP: 7.1.33 Page Time: 0.105s Queries: 14 (0.067s) Memory: 2.5174 MB (Peak: 3.0427 MB) Data Comp: Off Server Time: 2024-05-18 08:56:11 UTC
Valid HTML 5 and Valid CSS