Fixed Errors for SQL Functions