fixed sql error in event api