By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,086 Members | 1,452 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,086 IT Pros & Developers. It's quick & easy.

sqlplus exit statement prematurely terminates unix script

P: 3
#!/bin/ksh
echo ""
echo "Enter person ID:"
read person_id
sqlplus -silent '/nolog'<<end_sql1
connect useract/passwd
start $BANNER_LINKS/gurlsid.sql
$person_id
FAISMGR
end_sql1
cat person.lst >person_list
sqlplus -silent '/nolog'<<end_sql2
connect useract/passwd
start $BANNER_LINKS/gurlsid.sql
$person_id
FIMSMGR
end_sql2
cat person.lst >>person_list
sqlplus -silent '/nolog'<<end_sql2b
connect useract/passwd
spool person
set feedback off
column "Table Name" format a12
column "Column Name" format a30
column "Count" format 9999
column "Condition" format a32
select 'FOBTEXT' "Table Name",
'FOBTEXT_CODE' "Column Name",
count(fobtext_code) "Count",
'WHERE FOBTEXT_DTYP_SEQ_NUM = 73' "CONDITION"
from fobtext
where fobtext_code = '$person_id'
and fobtext_dtyp_seq_num = 73
having count(fobtext_code) > 0;
spool off
exit
end_sql2b
#--------------------------
cat person.lst >>person_list
echo ""
echo "finish my program"

*******

I am runing Oracle 10.2 on Sun OS.

The last three statements of this script did not execute at all. The last person.lst has something, but it didn't append to person_list. The last two echo didn't display on the screen either. I think somehow when exiting from sqlplus, it just exited out of the script completely.

Can someone indicate why the last three statements of this script did not carry out?

Thanks,
Trang
Sep 27 '06 #1
Share this Question
Share on Google+
3 Replies


P: 12
#!/bin/ksh
echo ""
echo "Enter person ID:"
read person_id
sqlplus -silent '/nolog'<<end_sql1
connect useract/passwd
start $BANNER_LINKS/gurlsid.sql
$person_id
FAISMGR
end_sql1
cat person.lst >person_list
sqlplus -silent '/nolog'<<end_sql2
connect useract/passwd
start $BANNER_LINKS/gurlsid.sql
$person_id
FIMSMGR
end_sql2
cat person.lst >>person_list
sqlplus -silent '/nolog'<<end_sql2b
connect useract/passwd
spool person
set feedback off
column "Table Name" format a12
column "Column Name" format a30
column "Count" format 9999
column "Condition" format a32
select 'FOBTEXT' "Table Name",
'FOBTEXT_CODE' "Column Name",
count(fobtext_code) "Count",
'WHERE FOBTEXT_DTYP_SEQ_NUM = 73' "CONDITION"
from fobtext
where fobtext_code = '$person_id'
and fobtext_dtyp_seq_num = 73
having count(fobtext_code) > 0;
spool off
exit
end_sql2b
#--------------------------
cat person.lst >>person_list
echo ""
echo "finish my program"

*******

I am runing Oracle 10.2 on Sun OS.

The last three statements of this script did not execute at all. The last person.lst has something, but it didn't append to person_list. The last two echo didn't display on the screen either. I think somehow when exiting from sqlplus, it just exited out of the script completely.

Can someone indicate why the last three statements of this script did not carry out?

Thanks,
Trang
The last SQL was not valid, hence your person.lst file would be empty.
In the list of columns and expressions for the select statement, you have an extra comma.

That would make life a bit difficult for you.
Dec 10 '06 #2

P: 1
#!/bin/ksh
echo ""
echo "Enter person ID:"
read person_id
sqlplus -silent '/nolog'<<end_sql1
connect useract/passwd
start $BANNER_LINKS/gurlsid.sql
$person_id
FAISMGR
end_sql1
cat person.lst >person_list
sqlplus -silent '/nolog'<<end_sql2
connect useract/passwd
start $BANNER_LINKS/gurlsid.sql
$person_id
FIMSMGR
end_sql2
cat person.lst >>person_list
connect useract/passwd
spool person
set feedback off
column "Table Name" format a12
column "Column Name" format a30
column "Count" format 9999
column "Condition" format a32
select 'FOBTEXT' "Table Name",
'FOBTEXT_CODE' "Column Name",
count(fobtext_code) "Count",
'WHERE FOBTEXT_DTYP_SEQ_NUM = 73' "CONDITION"
from fobtext
where fobtext_code = '$person_id'
and fobtext_dtyp_seq_num = 73
having count(fobtext_code) > 0;
spool off
exit
end_sql2b
#--------------------------
cat person.lst >>person_list
echo ""
echo "finish my program"

*******

I am runing Oracle 10.2 on Sun OS.

The last three statements of this script did not execute at all. The last person.lst has something, but it didn't append to person_list. The last two echo didn't display on the screen either. I think somehow when exiting from sqlplus, it just exited out of the script completely.

Can someone indicate why the last three statements of this script did not carry out?

Thanks,
Trang

====================
try adding the following:

sqlplus -silent '/nolog'<<end_sql2b >/dev/null
Jul 25 '07 #3

P: 1
I am facing the same issue...

script is terminating in between due to SQL exit

I am trying below script
cd $ROOT_APPLI/kcust/ddl
sqlplus -s e210/$PWD_E210@$DB_NAME <<FIN>
/E210/kcust/ddl
* @USERS_LDAP_SYNCHRO.sql $1 $1
commit;
exit 1;
FIN
cd $ROOT_APPLI/sh
script is terminating at exit line.

Please help
Mar 10 '10 #4

Post your reply

Sign in to post your reply or Sign up for a free account.