Seek UNIX script tutor and help

I am new to UNIX shell script programming. I have coded one korn shell script used on solaris 10 for Oracle database rman cold backup. The first part of script is working. But only following part is not working. Please help me to point out the problem and errors in my code. Thanks a lot.

# the first part has been omitted.

# Started to shutdown database and startup database mount for cold backup .

${ORACLE_HOME}/bin/sqlplus -s << EOF
conn / as sysdba
shutdown immediate;

${ORACLE_HOME}/bin/sqlplus -s << EOF
conn / as sysdba
startup mount;

# The above part works, then script stop here.

exit

rman NOCATALOG <<EOF
CONNECT TARGET SYS/$SYS_PASSWORD@$ORACLE_SID
if [ $? = 0 -o $? = 2 ]
then date +"%D %T: backup process started." >> pdedev$BACKUP_DAY.LOG
else date +"%D %T: Error start rman to do backup." >> pdedev$BACKUP_DAY.LOG
exit 1
fi
RUN
{
ALLOCATE CHANNEL ch1 DEVICE TYPE DISK
FORMAT = '$BACKUP_FOLDER/%d_DB_%u_%s_%p' MAXPIECESIZE 5G;
BACKUP DATABASE PLUS ARCHIVELOG DELETE ALL INPUT;
RELEASE CHANNEL ch1;

SQL 'ALTER SYSTEM ARCHIVE LOG CURRENT';
}
if [$? = 0]
then date +"%D %T: Rman backup successful." >> $BACKUP_DAY.LOG
echo "" >> $BACKUP_DAY.LOG
else date +"%D %T: Rman backup not successful." >> $BACKUP_DAY.LOG
date +"%D %T: Exiting script." >> $BACKUP_DAY.LOG
exit 1
fi

# Open database

$\{ORACLE_HOME\}/bin/sqlplus -s &lt;&lt; EOF
 conn / as sysdba
 alter database open; 
 echo " database $ORACLE_SID is up running." &gt;&gt; $BACKUP_DAY.LOG

exit
EOF

You are using <<EOF "here documents" without a closing EOF terminator. The whole remainder of the script gets passed to SQL (which ignores it, if it doesn't outright choke on it).

The "exit" is apparently not really supposed to be there? If it is, that's where the script terminates.

The "here document" syntax is a bit hard to grok until you get the hang of it. Maybe a few examples can help.

cat <<END_OF_FIRST_HERE_DOCUMENT

This will be copied to standard output
including this part which really looks a lot like a shell script
#!/bin/sh
echo frnod
exit 255
This is all just text as far as the shell is concerned,
so we don't care even that this looks like an unterminated
single-quoted string (because of the single quote between "don" and "t").
END_OF_FIRST_HERE_DOCUMENT

echo Script execution continues here

cat <<!
Another here document
you can use almost anything as a terminator
!

echo Back to the studio
exit 0

Era:

Thanks for your help. I will try again.