val resultList: List[List[String]] =
sql"""
select * from exchange_transaction
"""
.map(
rs =>
List(
rs.string("transaction_id")
)
)
.list()
.apply()
执行上面的代码,没问题,但是这个sql“select * from exchange_transaction”不固定。我想要这个 sql 像一个参数,就像下面(速记代码.....)
def findMemberList(segmentExecuteSql: String
val resultList: List[List[String]] =
sql"""
$segmentExecuteSql
"""
.map(
rs =>
List(
rs.string("transaction_id")
)
)
.list()
.apply()
但执行后出现错误消息是
[error] s.StatementExecutor$$anon$1 - SQL execution failed (Reason: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''select * from exchange_transaction'' at line 1
Query is :
'select * from exchange_transaction'
):
'select * from exchange_transaction'
我该怎么办,如何解决异常?