Solved

sqlplus command line

Posted on 2002-07-30
22
3,890 Views
Last Modified: 2008-02-26
hi,
i want to run a sql script from dos, i am doing the following:
sqlplus user/password@host @script.sql

it works fine, but it waits for the exit command,
is there a way to add the exit command to the command line ?

shay
0
Comment
Question by:Shay050799
  • 10
  • 6
  • 2
  • +4
22 Comments
 
LVL 34

Expert Comment

by:Mark Geerlings
ID: 7189020
Which exit, from SQLP*Plus back to DOS, or to exit from DOS?

You can add the "exit" command to the end of your *.sql file to have SQL*Plus exit back to DOS.

If you want to exit DOS automatically you may need to use a batch file with two lines:
sqlplus user/password@host @script.sql
exit

then run that batch file in DOS rather than typing in the command for SQL*Plus.
0
 
LVL 3

Author Comment

by:Shay050799
ID: 7189031
markgeer,
i can not edit the .sql file, i need to have it part of the sqlplus command line.

i need to exit SQL not DOS

Shay
0
 
LVL 2

Expert Comment

by:irinag
ID: 7189078
you can "wrap" your sql with another sql-script that looks like :
<<<
@script.sql
exit;
>>>

or create a batch-file script.bat:
<<<
sqlplus user/password@host @script.sql
exit
>>>

and run it from your dos-prompt
0
 
LVL 29

Expert Comment

by:MikeOM_DBA
ID: 7189082
Shay,

If you cannot edit the original script?, then create a new script with these lines:

@script.sql
exit

And that will do it!

sqlplus user/password@host @new_script.sql

MikeOM>
0
 
LVL 3

Author Comment

by:Shay050799
ID: 7189094
irinag,
i am getting this error:
<< was unexpected at this time.

i did this:
sqlplus <<< user/user123@mho2.world @install.sql exit; >>>

shay
0
 
LVL 3

Author Comment

by:Shay050799
ID: 7189098
irinag,
i am getting this error:
<< was unexpected at this time.

i did this:
sqlplus <<< user/user123@mho2.world @install.sql exit; >>>

shay
0
 
LVL 2

Expert Comment

by:irinag
ID: 7189100
:)


sorry Shay if I confused you...

what I ment is create another sql-file and pute lines between <<....>> in this new file

irina
0
 
LVL 2

Expert Comment

by:irinag
ID: 7189101
:)


sorry Shay if I confused you...

what I ment is create another sql-file and pute lines between <<....>> in this new file

irina
0
 
LVL 2

Expert Comment

by:irinag
ID: 7189107
:)


sorry Shay if I confused you...

what I ment is create another sql-file and pute lines between <<....>> in this new file

irina
0
 
LVL 3

Author Comment

by:Shay050799
ID: 7189108
umm..
can't do that :-)
unix allows you to do that though..why i m unable to do it in dos ?

shay
0
 
LVL 2

Expert Comment

by:irinag
ID: 7189115
sorry...

You can do many "good" things easily in unix, but not in DOS..
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 2

Expert Comment

by:irinag
ID: 7189136
sorry...

You can do many "good" things easily in unix, but not in DOS..
0
 
LVL 2

Accepted Solution

by:
irinag earned 20 total points
ID: 7189150
one more try ..

if you create a new file (let's say e.txt)
with one line/word "exit" (no " )

then your command line can look like :
 user/user123@mho2.world @install.sql < e.txt

0
 
LVL 4

Expert Comment

by:asimkovsky
ID: 7189302
Why can't you edit the .sql file? It's just a text file.


Andrew
0
 
LVL 3

Author Comment

by:Shay050799
ID: 7190534
well thats not what i was looking for, but i guess its the best i can get with dos

thanks
Shay
0
 
LVL 3

Expert Comment

by:rkogelhe
ID: 7190852
c:\>echo exit | sqlplus /nolog

SQL*Plus: Release 9.0.1.0.1 - Production on Wed Jul 31 17:15:55 2002

(c) Copyright 2001 Oracle Corporation.  All rights reserved.

SQL>
c:\>
0
 
LVL 2

Expert Comment

by:irinag
ID: 7190873
rkogelhe,

wow!! it really works!
even this one works :
 exit|sqlplus user/user123@mho2.world

thanks for good piece of information

irina
0
 
LVL 2

Expert Comment

by:irinag
ID: 7190897
now I feel guilty...do not deserve these points...
is there way to give them to RKOGELHE ?
0
 
LVL 3

Author Comment

by:Shay050799
ID: 7190928
irinag ,
i am unable to use RKOGELHE  solutions.
i am using Ant to run sqlplus, i can not have anything before sqlplus command
what i was doing is:
i copy the .sql into a tempfile, append an exit; tot he end of it,
and ran the regular sqlplus command with a single file which is the new temp file

shay
0
 
LVL 2

Expert Comment

by:irinag
ID: 7190936
now I feel guilty...do not deserve these points...
is there way to give them to RKOGELHE ?
0
 

Expert Comment

by:vsaravan
ID: 7606210
Similary I have one more requirement in Win2000

I created a batch file C:\Winnt\System32\RunIsql.bat

it contains

isqlw.exe -Usa -P -DMyDb -S(local) -f%1

and associated .sql extentionsion to this RunIsql.bat file

Whenever I double click .sql file it immediately opens query analyser and sql file text is available for editing.

This is very useful in my development system. Because every time I need not give sql username and password.

It opens the sql file with query analyser very well. But one problem is there. One more cmd.exe is also opened behind. It exists until I close the query analyser. How to avoid that?

adding exit statement does not work

isqlw.exe -Usa -P -DMyDb -S(local) -f%1
exit




0
 

Expert Comment

by:vsaravan
ID: 7606250
I got answer from Expert Exchange
start isqlw.exe -Usa -P -Droutine -S(local) -f%1
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now