sqlplus command line

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
LVL 3
Shay050799Asked:
Who is Participating?
 
irinagConnect With a Mentor Commented:
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
 
Mark GeerlingsDatabase AdministratorCommented:
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
 
Shay050799Author Commented:
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
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
irinagCommented:
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
 
MikeOM_DBACommented:
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
 
Shay050799Author Commented:
irinag,
i am getting this error:
<< was unexpected at this time.

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

shay
0
 
Shay050799Author Commented:
irinag,
i am getting this error:
<< was unexpected at this time.

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

shay
0
 
irinagCommented:
:)


sorry Shay if I confused you...

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

irina
0
 
irinagCommented:
:)


sorry Shay if I confused you...

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

irina
0
 
irinagCommented:
:)


sorry Shay if I confused you...

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

irina
0
 
Shay050799Author Commented:
umm..
can't do that :-)
unix allows you to do that though..why i m unable to do it in dos ?

shay
0
 
irinagCommented:
sorry...

You can do many "good" things easily in unix, but not in DOS..
0
 
irinagCommented:
sorry...

You can do many "good" things easily in unix, but not in DOS..
0
 
asimkovskyCommented:
Why can't you edit the .sql file? It's just a text file.


Andrew
0
 
Shay050799Author Commented:
well thats not what i was looking for, but i guess its the best i can get with dos

thanks
Shay
0
 
rkogelheCommented:
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
 
irinagCommented:
rkogelhe,

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

thanks for good piece of information

irina
0
 
irinagCommented:
now I feel guilty...do not deserve these points...
is there way to give them to RKOGELHE ?
0
 
Shay050799Author Commented:
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
 
irinagCommented:
now I feel guilty...do not deserve these points...
is there way to give them to RKOGELHE ?
0
 
vsaravanCommented:
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
 
vsaravanCommented:
I got answer from Expert Exchange
start isqlw.exe -Usa -P -Droutine -S(local) -f%1
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.