0

我正在寻找这样做:

update aTable 
set aField = 'value' 
where aTable.Id in (select top 400 Id from aTable order by dateField) .
-- This will run, but it only updates the first id it gets to in the IN clause

或这个:

update top 400 aTable set aField = 'value' order by dateField 
-- This will not run

但是,它必须在 Pervasive V10 中工作......

类似的解决方法也足够了!

背景,我正在尝试使用按日期字段排序的值更新(项目数(变量))的字段。

这是 Pervasive 的更新帮助(我没有在其中看到 TOP 保留字):

UPDATE < table-name | view-name > [ alias-name ]

SET column-name = < NULL | DEFAULT
 | expression | subquery-
expression > [ , column-name = ... ] 
 [ FROM table-reference [, table-reference ] ...
 [ WHERE search-condition ]

table-name ::= user-defined-name 
 view-name ::= user-defined-name 
 alias-name ::= user-defined-name (Alias-name is not allowed if a 
FROM clause is used. See FROM Clause .)

 table-reference ::= { OJ outer-join-definition }

| [db-name.]table-name [ [ AS ] alias-name ]
 | [db-name.]view-name [ [ AS ] alias-name ]
 | join-definition | ( join-definition )
 | ( table-subquery )[ AS ] alias-name [ (column-name [ , column-name 
]... ) ]
4

1 回答 1

1

我做了一些测试,最好的方法是创建一个视图:

创建视图 View1 作为从 aTable order by dateField 中选择 Id;

然后使用更新中的视图:

update aTable set aField = 'value' where aTable.Id in (select top 400 a.Id from View1 a );

我已经使用 PSQL v11 进行了测试,但它也应该适用于 PSQL v10。

于 2011-01-07T19:15:52.377 回答