Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
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

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.

The script is:
#!/usr/bin/ksh
path_1=/appworx/dir01/file1/script1sqlplus -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.csvselect 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 sqlpluskalyan

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

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

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.

try this for your file:
/
set serveroutput on size 50000
spool /appworx/dir01/file1/script1/test10.csvselect 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.

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

![]() |
![]() |
![]() |

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