Print Thread
Command Window: @@ does not work as expected
#26606 05/31/07 05:53 PM
Joined: Sep 2006
Posts: 3
CH
J
Member
OP Offline
Member
J
Joined: Sep 2006
Posts: 3
CH
The instruction "@@file.sql" in a command file is expected to run "file.sql" in the same directory as the calling command file - this is the behaviour of SQL*Plus and of PL/SQL Developer 7.0.

But currently (7.1.1.1339), PL/SQL Developer first looks somewhere deep in my home directory (how did it find that???) for a file of this name, which is not what I expected: The calling command file resides on another drive.

In the Preferences, the default directory for Command Files is set to a subfolder "PLSQL Developer Data" my home directory.

Re: Command Window: @@ does not work as expected
#26607 05/31/07 07:01 PM
Joined: Aug 1999
Posts: 22,208
Member
Offline
Member
Joined: Aug 1999
Posts: 22,208
It searches in the following directories (in order of precedence):
  1. The default directory of PL/SQL Developer.
  2. The directory of the calling script (if any).
  3. The Command file directory specified in the preferences.
  4. The directories specified in the SQLPATH Oracle registry key.
  5. The directories specified in the ORACLE_PATH Oracle registry key.


Marco Kalter
Allround Automations
Re: Command Window: @@ does not work as expected
#26608 08/02/07 04:25 PM
Joined: Aug 2007
Posts: 3
C
Member
Offline
Member
C
Joined: Aug 2007
Posts: 3
Hi all,

I would also say that the @@ command does not work correctly:

I have the following script directories

c:/master
----------
master.sql

c:/master/1
-----------
1.sql
2.sql

master.sql:
-----------
@1/1.sql
calls 1.sql correctly.

1.sql:
------
@@2.sql
does *NOT* find 2.sql (Error reading file)

Re: Command Window: @@ does not work as expected
#26609 08/02/07 05:04 PM
Joined: Aug 1999
Posts: 22,208
Member
Offline
Member
Joined: Aug 1999
Posts: 22,208
Does it work in SQL*Plus?


Marco Kalter
Allround Automations
Re: Command Window: @@ does not work as expected
#26610 08/02/07 08:45 PM
Joined: Aug 2007
Posts: 3
C
Member
Offline
Member
C
Joined: Aug 2007
Posts: 3
It does work in TOAD. We are currently evaluating PL/SQL developer as an alternative to TOAD but this is a major show stopper. We have complex nested scripts which use this feature (run from the same directory as the calling command file) extensively. I believe SQL*Plus works correctly with these scripts (though our Oracle developers run them in TOAD, but they say they work in SQL*Plus) but I have not tested it myself.

Fun stuff: If I run master.sql from its directory it does not work. If I open and run 1.sql from its directory in another Command window 1.sql works. If I run master.sql again (even with 1.sql Command window closed) it works correctly (by miracle). I think the @@ needs some work, since the behaviour of it is somewhat unpredictable right now. And that is bad if you need to depend on it.

Re: Command Window: @@ does not work as expected
#26611 08/03/07 05:36 PM
Joined: Aug 1999
Posts: 22,208
Member
Offline
Member
Joined: Aug 1999
Posts: 22,208
I couldn't reproduce it correctly in SQL*Plus either, but we'll check it out. It doesn't seem to work correctly right now.


Marco Kalter
Allround Automations
Re: Command Window: @@ does not work as expected
#26612 08/06/07 03:40 PM
Joined: Aug 2007
Posts: 3
C
Member
Offline
Member
C
Joined: Aug 2007
Posts: 3
Thanks. According to orafaq.com: "What is the difference between @ and @@?" "@@ will start a sqlplus script that is in the same directory as the script that called it [...]."
It would be nice if you could make it work like it was intended to work by SQL*Plus documentation.
Again, thanks for your efforts.

Re: Command Window: @@ does not work as expected
c/FX #56016 03/01/17 10:45 PM
Joined: Jul 2016
Posts: 20
J
Member
Offline
Member
J
Joined: Jul 2016
Posts: 20
(Found this old thread after considerable searching. I couldn't figure out how to make the forum search for the string "@@" so apologies if I missed a more recent discussion on this.)

The Oracle SQL*Plus documentation on "@" vs "@@" seems pretty clear that they are different and that "@@" should search relative to the directory of the currently running script, but PL/SQL Developer doesn't appear to work that way.

Marco, I've seen you document the precedence of directories searched a couple times. I'm unclear about whether that's for "@" or "@@" or both. You've said the order is:

1. The default directory of PL/SQL Developer.
2. The directory of the calling script (if any).
3. The Command file directory specified in the preferences.
4. The directories specified in the SQLPATH Oracle registry key.
5. The directories specified in the ORACLE_PATH Oracle registry key.

If that's true of "@@" then as long as the script doesn't exist in the default directory (#1) then #2 should effectively cause "relative to the currently running script" to work which, I think, is compatible with SQL*Plus.

Does the searching consider relative folder paths if they are included in the script name?

I'm trying to construct a folder structure of scripts like:

main.sql
script1.sql
script2.sql
subdirectory/main.sql
subdirectory/script1.sql
subdirectory/script2.sql

...where a subdirectory can be a self-contained unit with its' own "main.sql" which can call other scripts in the same directory without qualifying them with any directory names.

So the starting, top-level "main.sql" script could be:

@@'script1.sql'
@@"subdirectory/main.sql"
@@'script2.sql'

And the script at "subdirectory/main.sql" could be:

@@'script1.sql'
@@'script2.sql'

Beginning execution at the top-level main.sql, it should execute the top-level "script1.sql" then dive into the subdirectory to execute the other "main.sql" which would call its' own "script1.sql" and "script2.sql".

After execution comes back out of the "subdirectory/script.sql" and returns to the top-level "script.sql", the final unqualified reference to "script2.sql" should execute the one in the original top-level directory.

Is this possible, should I use "@" or "@@" and is it compatible with the way SQL*Plus works?




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.057s Queries: 15 (0.016s) Memory: 2.5339 MB (Peak: 3.0393 MB) Data Comp: Off Server Time: 2024-05-05 14:25:39 UTC
Valid HTML 5 and Valid CSS