上記のクエリは、Oracle 10g で正常に実行されます。今度は、SQLSERVER 2005 を使用して同じクエリ (アプリケーション) を実装する必要があります。
SQLSERVER 2005 で上記のクエリを実行すると、「FOR UPDATE 句は DECLARE CURSOR にのみ許可されています」というエラーが表示されます。
上記のクエリは SQLSERVER 2005 でサポートされていますか? それとも代替品はありますか?
標的:
基本的に、アプリケーションの文書を更新しています。私はチャンク更新を使用しており、新しいコンテンツごとに毎回古いコンテンツを追加する必要があります。
コード:
Blob bb = getDataAccess().executeScalar( "select content from Repository where id = ? for update", getId());
os = bb.setBinaryStream(startIndex + 1);
while ((read = content.read(buf)) > 0) {
os.write(buf, 0, read);
startIndex += read;
//commit every megabate or every second so upload progress is visible
//and we don't lose more than 1MB if something happens.
if (startIndex - lastStartIndex > bufSize || (new Date().getTime() - lastUpdateTime) > UPDATE_INTERVAL) {
os.close();
os = null;
getDataAccess().executeUpdate("UPDATE Repository SET LastChunkSaved = CURRENT_TIMESTAMP WHERE ID = ?", getId());
getDataAccess().commit();
lastStartIndex = startIndex;
lastUpdateTime = new Date().getTime();
bb = getDataAccess().executeScalar( "select content from Repository where id = ? for update", getId());
os = bb.setBinaryStream(startIndex + 1);
totalSaved += startIndex - lastStartIndex;
}
}
os.close();