If condition and htm not working

checkSync()
{
        CONNECT_STRING=TLDB61/TLDB61@TL10G
        SQLPLUS_SETTINGS="SET PAGESIZE 0 LINESIZE 1500 ECHO OFF TRIMS ON TAB OFF FEEDBACK OFF HEADING OFF"
        SQL_RESULT_SYNC_PMCM=`sqlplus -s ${CONNECT_STRING} << EOF
        ${SQLPLUS_SETTINGS}
        (SELECT CYCLE_CODE,CYCLE_MONTH,CYCLE_START_DATE, CYCLE_CLOSE_DATE FROM PM1_CYCLE_STATE MINUS SELECT CYCLE_CODE,CYCLE_I
NSTANCE,CYCLE_START_DATE, CYCLE_END_DATE FROM CM1_CYCLE_INSTANCE) UNION (SELECT  CYCLE_CODE,CYCLE_INSTANCE,CYCLE_START_DATE, C
YCLE_END_DATE FROM CM1_CYCLE_INSTANCE MINUS SELECT CYCLE_CODE,CYCLE_MONTH,CYCLE_START_DATE, CYCLE_CLOSE_DATE FROM PM1_CYCLE_ST
ATE);
        exit;
        EOF`

         if [$SQL_RESULT_SYNC_PMCM != 0]        then
                 echo "$SQL_RESULT_SYNC_PMCM" | mailx -s "FAILURE - Check the pm1_cycle_state and cm1_cycle_instance not in sy
nc" abc.ef@xyz.com


        fi

        echo "$SQL_RESULT_SYNC_PMCM" | awk ' \
BEGIN{
print ""
print "<html><body><table cellpadding=2 cellspacing=0 style=\047border-style: ridge; font-family: Verdana, Arial, Helvetica, s
ans-serif; font-size: 12px; font-weight:bold\047>"
print "<tr style=\047color: white; background-color:6DA2D7\047><td>CYCLE_CODE</td><td>CYCLE_MONTH</td><td>CYCLE_START_DATE</td
><td>CYCLE_CLOSE_DATE</td></tr>"
}
{print "<tr bgcolor=CCCCCC><td>" $1 "</td><td>" $2 "</td><td>" $3 "</td><td>" $4 "</td> "</td></tr>" }
END {
print "</table></body></html>"
}' > ALERT.htm

}

In the above code I am trying to collect a result from a query to (SQL_RESULT_SYNC_PMCM)

Then checking if the content is not zero (how to check it ) my condition is not working.

Also trying to collect it in a htm which is also not working

Please help correct the code.

Instead of

if [$SQL_RESULT_SYNC_PMCM != 0]        then

try

if [ "${SQL_RESET_SYNC_PMCM}" -ne 0 ] ; then

This line should start in column 1 and must not be indented.

EOF`

With the "EOF" line misplaced everything from that line onwards was being given to sqlplus not shell.
This is why you didn't get a syntax error for the faulty "if" statements.