Quantcast
Channel: UNIX and Linux Forums
Viewing all articles
Browse latest Browse all 16232

issues with sql inside if statement

$
0
0
Hi,

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.

Code:

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
}


Viewing all articles
Browse latest Browse all 16232

Latest Images

Trending Articles



Latest Images