I am using ScalikeJDBC in my project and I have an SQL query like this
val str = "select name, age from employee"
val selectQueryString = sqls"$str"
val like = "%" + term + "%"
val emp: List[Employee] = db.localTx { implicit session =>
sql"#$selectQueryString where name like ${like} order by age"
.map(rs => Employee(rs.string("name"), rs.int("age")))
.list()
.apply()
}
But when I run the program I get Error like this.
Failed preparing the statement (Reason: Parameter index out of range (1 > number of parameters, which is 0
My requirement is, I already have a safe SQL query which is a string and I want to add conditions to that, so that the query is safe from SQL injection.