以下是查询:
UPDATE einvoice_message AS e1
SET message = null
FROM (
SELECT *
FROM einvoice_message
where created < :created
ORDER BY :created LIMIT :limit
FOR UPDATE SKIP LOCKED
) AS e2
WHERE e1.einvoice_message_id = e2.einvoice_message_id
RETURNING e1.einvoice_message_id
我要走了 SqlExceptionHelper - The column name created was not found in this ResultSet.
不明白为什么在哪里?我需要帮助。
java代码:
@Query(value = "UPDATE einvoice_message AS e1 SET message = null FROM (SELECT * FROM einvoice_message
where created < :created ORDER BY :created LIMIT :limit FOR UPDATE SKIP LOCKED) AS e2 WHERE
e1.einvoice_message_id = e2.einvoice_message_id RETURNING e1.einvoice_message_id", nativeQuery = true)
List<EinvoiceMessage> deleteEinvoiceMessageContent(@Param("created") OffsetDateTime created,
@Param("limit") int limit);
这是我的ddl表:
create table einvoice_message
(
einvoice_message_id bigserial not null
constraint einvoice_message_pk
primary key,
message bytea not null,
created timestamp default now() not null
);
改变 :created
变量到列 created
没有解决问题。
1条答案
按热度按时间7gcisfzg1#
问题在于它的返回值。
RETURNING e1.einvoice_message_id
将返回一个数字,而不是我刚才提到的列表。正确答案是: