Ich beschränke meine Kritik auf den Hinweis, dass Ihr Tabellenentwurf nicht normalisiert und wenig elegant ist – ich nehme aber an, Sie haben Ihre Gründe. Solche „Rotations“-Abfragen löse ich üblicherweise mit DECODE in Kombination mit einer Aggregatspalte, gruppiert nach meinem Schlüssel (hier Ihr Pseudoschlüssel trunc(ID/100)). Kombiniert mit der Update-Syntax, die Tupel verwendet:
UPDATE Foo SET (a, b, c, d) = (w, x, y, z);
ergibt sich:
UPDATE KeyMap SET ( key1 , key2 , key3 , key4 ... , key99 ) = ( SELECT MAX(decode(mod(ID, 100), 1, Key, NULL)) , MAX(decode(mod(ID, 100), 2, Key, NULL)) , MAX(decode(mod(ID, 100), 3, Key, NULL)) , MAX(decode(mod(ID, 100), 4, Key, NULL)) ... , MAX(decode(mod(ID, 100), 99, Key, NULL)) FROM Source WHERE Trunc(Source.ID / 100) = KeyMap.batchId GROUP BY Trunc(Source.ID / 100) ) WHERE BatchId = <x>;