Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3907
  • Last Modified:

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
0
Shay050799
Asked:
Shay050799
  • 10
  • 6
  • 2
  • +4
1 Solution
 
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
 
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
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 
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
 
irinagCommented:
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
 
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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 10
  • 6
  • 2
  • +4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now