以下查询在hsqldb 2.3.2中失败,sql.syntax_ora = true
在Oracle 11中正常工作。
它是一个名为hibernate的查询,用于TestNG测试,用于内存中的hsqldb,而不是真正的Oracle。
错误消息是:java.sql.SQLSyntaxErrorException:意外令牌:需要ORDER:):line:16,指的是 row_number()over(按lastUpdateTime desc排序)区域:
select
id as id1_9_0_,
version as version2_9_0_,
lastUpdateTime as lastUpda7_9_0_,
eventType as eventTyp3_9_0_,
clientJid as clientJi4_9_0_,
topicName as topicNam5_9_0_,
attributes as attribut6_9_0_
from (select logEvents.id as id,
logEvents.version as version,
logEvents.lastUpdateTime as lastUpdateTime,
logEvents.eventType as eventType,
logEvents.clientJid as clientJid,
logEvents.topicName as topicName,
logEvents.attributes as attributes,
row_number() over (order by lastUpdateTime desc) rn from xyz_logEvent logEvents)
where rn between 1 and 4 order by rn;
答案 0 :(得分:0)
HSQLDB并不支持所有可能的SQL语法。 row_number() over (order by ...)
为row_number() over ()
时不支持(select logEvents.id as id,
logEvents.version as version,
logEvents.lastUpdateTime as lastUpdateTime,
logEvents.eventType as eventType,
logEvents.clientJid as clientJid,
logEvents.topicName as topicName,
logEvents.attributes as attributes,
row_number() over () rn from xyz_logEvent logEvents order by lastUpdateTime limit 4)
。
替代方案可能如下所示:
{{1}}