Computing.Net > Forums > Unix > Exit from sqlplus in a shell script

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Exit from sqlplus in a shell script

Reply to Message Icon

Name: kalyanbrata.dhar
Date: November 4, 2008 at 21:48:11 Pacific
OS: Unix
CPU/Ram: ...
Product: ...
Comment:

Hi,

I have written a shell script in which I need to connect to sqlplus and execute some query there. In doing so on executing the shell script the query gets executed successfully but is not able to exit from sqlplus and as a result the shell script falls into a loop. Please suggest me the possible solution

kalyan



Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: November 5, 2008 at 11:42:54 Pacific
Reply:

Two suggestions:

1) You'll probably not get help without posting code examples stating exactly what the problem is.

2) Search this forum for 'sqlplus'. There are a number of examples which might help you.


0

Response Number 2
Name: kalyanbrata.dhar
Date: November 5, 2008 at 21:25:12 Pacific
Reply:

The script is:

#!/usr/bin/ksh
path_1=/appworx/dir01/file1/script1

sqlplus -s loginid/password@AW01 @/appworx/dir01/file1/script1/Test.sql

job1.1=$(grep "ABC" $path_1/test10.csv | awk '{print $2}')

echo ABC,$job1.1 > $path_1/testoutput.csv


AND THE QUERY IS in Test.sql:

set serveroutput on size 50000
spool /appworx/dir01/file1/script1/test10.csv

select so_module,
to_char(SO_JOB_STARTED,'HH24:MI')
SO_START_DATE
from so_job_history
where so_module in (
'ABC',
'DEF'
)
and so_job_finished between sysdate-1 and sysdate ;

spool off


The query is getting executed properly but after that its not coming out from sqlplus

kalyan


0

Response Number 3
Name: nails
Date: November 5, 2008 at 22:32:44 Pacific
Reply:

I'm not an Oracle guy, but most of the guys I know use a Unix here document. Check these 2 links out:

http://www.computing.net/answers/un...

http://www.computing.net/answers/un...


0

Response Number 4
Name: kalyanbrata.dhar
Date: November 6, 2008 at 22:35:21 Pacific
Reply:

I tried by adding:
EXIT
EOF
at the end of Sql query but still its not working.

Could anyone help me out regarding this.

kalyan


0

Response Number 5
Name: James Boothe
Date: November 12, 2008 at 12:28:51 Pacific
Reply:

You do not need the EOF since you are not using a here-document. But adding the EXIT to your sql script should have worked. The EOF on the following line would not hurt, as it would exit first.

If this is still an issue, please post the latest version of your sql script.


0

Related Posts

See More



Response Number 6
Name: lankrypt0
Date: November 14, 2008 at 11:04:50 Pacific
Reply:

try this for your file:

/
set serveroutput on size 50000
spool /appworx/dir01/file1/script1/test10.csv

select so_module,
to_char(SO_JOB_STARTED,'HH24:MI')
SO_START_DATE
from so_job_history
where so_module in (
'ABC',
'DEF'
)
and so_job_finished between sysdate-1 and sysdate ;

spool off
EXIT
/

That's the way I have all of mine structured when I run queries within ksh scripts and it works fine.


0

Response Number 7
Name: kalyanbrata.dhar
Date: November 19, 2008 at 03:33:40 Pacific
Reply:

Thank you the issue has been solved now. But on the other side in sql query I have stuck at a point.For the table given below
Coloumn 1 Time

A 6:30
B 6:00
V 5:30
D 5:00
A 4:30
D 4:00
C 3:30
V 3:00
B 2:30
I want only the recent run of all the jobs.Like for job a I want only the 6:30 run.

could you please help me in this. This is in sqlplus.

kalyan


0

Response Number 8
Name: SysLock
Date: December 10, 2008 at 19:37:24 Pacific
Reply:

Try unix.about.com

Silence is golden but duct tape is silver


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Exit from sqlplus in a shell script

Auto say y or n in a shell script www.computing.net/answers/unix/auto-say-y-or-n-in-a-shell-script/4059.html

Parameter file for a shell script www.computing.net/answers/unix/parameter-file-for-a-shell-script/6026.html

Timer in a shell script www.computing.net/answers/unix/timer-in-a-shell-script/4097.html