I am trying to write a bash function which should delete some entries from table1 if the user enters 1, otherwise remove different entries. My function looks like this:
function reset_db
{
if [ $usr_input == 1 ]
then
sqlplus -s $USR/$pwd@$SID << EOF
delete from table1 where component = 'ABC';
delete from table2 where component = 'ABC';
exit
EOF
else if [ $usr_input == 2 ]
delete from table1 where component = 'XYZ';
delete from table2 where component = 'XYZ';
exit
EOF
fi
}
I am getting error: syntax error near unexpected token `fi'
I am sure that it is happening because I am using if-else incorrectly somewhere but not able to figure out a way to fix it.
Also please let me know how can I post code under the same thread if I have any more follow up questions.