我正在尝试通过检查uuids
是否匹配传递给选择语句的数组中的任何值来从表中提取行。
SELECT * FROM table_name WHERE uuid_column IN ({comma_separated_uuids})
val existingCustomers = fetchRows(
ctx, generateSQLForTuples(tuples), mapOf("uuids" to customers.map { it["uuid"] as UUID })
)
下面是generateSQLForTuples
函数的代码:
private fun generateSQLForTuples(tuplesList: List<List<String>>):String =
// language=PostgreSQL
"""
select id, subcustomer
from customer
where uuid in (:uuids)
union
select id, subcustomer
from customer
where (customer_id, subcustomer) in (${toJdbcTuples(tuplesList)})
""".trimIndent()
但是,我遇到了错误:
PSQLException: ERROR: operator does not exist: uuid = uuid[]
我在这里做错了什么,如何将包含UUID值的数组传递给选择语句?
where uuid = any(:uuids)
。 - user330315toJdbcTuples
是什么?看起来你正在处理一个列表的列表,而不是元组的列表。 - BergiIN
就可以使用值列表,例如in (1,2,3)
。 - user330315(1, 2, 3)
相同吗? - Leff