I have problem with the following code. My IF block is not executed. And I see "syntax error near unexpected token `)'" error for line "EOF" in the stats_function().
but when I comment the IF block I don't see this error.
Kindly help me with this issue.
clean_function()
{
count_clean=$(sqlplus -s username/password@SID<<-EOF
SET HEADING OFF
SET FEEDBACK OFF
SET PAGES 0
select count(*) from tableA;
quit
EOF
)
echo $count_clean
}
count2_clean=$(clean_function)
echo $count2_clean
if [ $count2_clean -ne 0 ];then
sqlplus -s $(sqlplus -s username/password@SID<<-EOF
SET HEADING OFF
SET FEEDBACK OFF
SET PAGES 0
delete from tableA;
quit
EOF
fi
######################## RUN THE SCRIPT TO LOAD THE DB ######################
sh dbloadscript
######################## CHECK THE STATUS OF THE DB ###########################
stats_function()
{
count_status=$(sqlplus -s username/password@SID<<-EOF
SET HEADING OFF
SET FEEDBACK OFF
SET PAGES 0
select count(*) from tableA where status=a;
EOF
)
return $count_status
}
which editor you are using. Normally editors will show what you are missing. specially with the ( and { ..:)(i am using Notepad++)
there is no closing bracket for below highlighted.. (
if [ $count2_clean -ne 0 ];then
sqlplus -s $(sqlplus -s username/password@SID<<-EOF
SET HEADING OFF
SET FEEDBACK OFF
SET PAGES 0
delete from tableA;
quit
EOF
fi
yes.. that is why I am confused.... I have checked my actual code in notepad++... the braces are fine.... like I said earlier if i comment IF statement ... I don't have the error... but with the IF statement I get that error....
my IF statement looks like ... the first post had a typo
if [ $count2_clean -ne 0 ];then
sqlplus -s username/password@SID<<-EOF
SET HEADING OFF
SET FEEDBACK OFF
SET PAGES 0
delete from tableA;
quit
EOF
fi
Does your closing EOF have a tab character in front of it? The dash before the first EOF means ignore leading tabs in front of the closing EOF.
On my system, it did not work if there were spaces in front of the closing EOF.