Above query runs successfully on Oracle 10g. Now I have to implement same query(Application) using SQLSERVER 2005.
When I am running Above Query in SQLSERVER 2005 I am getting error "FOR UPDATE clause allowed only for DECLARE CURSOR".
Is above query supported by SQLSERVER 2005? Or is there any alternate?
Aim:
Basicaly I am updating ducument in my application. I am using chunked update and I have to append every time old content by new content.
CODE:
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();