Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Invoking sqlplus scripts

Status
Not open for further replies.

jhammer98

Programmer
Apr 21, 2005
24
0
0
US
To forewarn you...This is potentially a very stupid question.

I'm trying to figure out why things aren't running consistently in one of my batches. While perusing the logs I've only found one difference between the several runs. The script that is producing varying results is called like this:

Code:
sqlplus / < blah.sql

whereas all the other scripts in the stream are called like this:

Code:
sqlplus / @blah.sql

I've never seen the '<' before, so my question is...what is the difference between invoking a sql script with a '<' versus an '@'?

TIA

~Jake
 
Heres what I got when I tried:

depending on whether there is an exit at the end of your sql script -

The first one (with /) seems to exit out to the prompt.

The second one (with @) keeps the sqlplus session open.
 
In your case, Jake, there is no effective difference. In practice, when you use the "@" invocation, the default file type is ".sql"; when you use the "<" invocation, there is no default file type, and you must explicitly specify the ".sql" suffix.

And your question, by no means, was stupid.[smile]

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[ Providing low-cost remote Database Admin services]
Click here to join Utah Oracle Users Group on Tek-Tips if you use Oracle in Utah USA.
 
I have noticed a slight difference in the output...

the '@' produces
'H
--
Hi


'H
--
Hi

from this script:
Code:
select 'Hi' from dual;
/
quit

When I ran it with the '<', I got the following: (notice the prompts)

[highlight]SQL> [/highlight]
'H
--
Hi

[highlight]SQL> [/highlight]
'H
--
Hi

I don't see how this could affect the data manipulated by the script though?!?!?!?
 
J,

I should have pointed our that another difference is that the "@" mode means "execute a script"; "<" means "pipe the contents of a file to the running application as though an operator were entering each incoming character via the keyboard." Ergo, "the rules" that SQL*Plus follows for running a script versus entering commands from the keyboard (including "SQL" prompt display) can be, and are, different from one another.

As an example (but not necessarily an issue in your case), SQL*Plus's command "set echo off" has no effect for keyboard entry; the effect results only when running a script.

I don't know if this information produces a satisfactory resolution for you or not. Let us know.

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[ Providing low-cost remote Database Admin services]
Click here to join Utah Oracle Users Group on Tek-Tips if you use Oracle in Utah USA.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top