Correct sql query for application parameters (closes #4087)

+ Correct deprecated calls