0

上記のクエリは、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();
4

1 に答える 1

4

私は同様の問題に遭遇し、「SelectMethod=Cursor」を接続 URL に追加するのに役立ちました。

jdbc:sqlserver://<server>\SQLEXPRESS:1433;databaseName=<db>;SelectMethod=Cursor;integratedSecurity=true;

実際、私はこれを簡単に見つけることができなかったので、もっと早く見つけられたはずの場所に追加しました。

于 2015-08-27T15:21:31.580 に答える