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

私はいくつかのテストを行いましたが、これを機能させるための最良の方法は、ビューを作成することです:

aTable order by dateField から選択 ID としてビュー View1 を作成します。

次に、更新でビューを使用します。

update aTable set aField = 'value' where aTable.Id in (View1 a から上位 400 の a.Id を選択);

PSQL v11 でテストしましたが、PSQL v10 でも動作するはずです。

于 2011-01-07T19:15:52.377 に答える