Solved

sqlplus command line

Posted on 2002-07-30
22
3,897 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 10
  • 6
  • 2
  • +4
22 Comments
 
LVL 35

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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Character matching different date formats for dates between 6 82
add more rows to hierarchy 3 46
update statement in oracle 9 53
pl/sql parameter is null sometimes 2 39
Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
Shell script to create broker configuration file using current broker Configuration, solely for purpose of backup on Linux. Script may need to be modified depending on OS-installation. Please deploy and verify the script in a test environment.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

739 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