0

如果可能,我想将以下 PL/SQL 语句优化为单个SELECT+UPDATESQL 语句。

--Key is a VARCHAR2, Value is a CLOB
FOR Pair IN (select Key, Value from PairTable) 
LOOP           
  update UpdatableTable
  set CLOBColumn = CLOBColumn || Pair.Value
  where ID in
    (select ID from UpdatableTable
    where CONTAINS("indexedcolumns", '{' || Pair.Key || '}') > 0); 
  commit;
END LOOP;

问题是我需要在同一个'子句中使用UPDATE'子句的部分结果。从概念上讲,我想首先将. 然后使用字符串查看它是否包含在. 然后将字符串(与上述字符串对应)设置为's 。WHEREUPDATESETSELECTPairTableKeyUpdatableTableValueKeyUpdatableTableCLOBColumn

4

2 回答 2

1

至少FORALL在 PLSQL 中使用 a 。

于 2013-01-23T13:29:06.827 回答
0
you can use the below update statements

update UpdatableTable
  set CLOBColumn = CLOBColumn || Value from PairTable
  where ID in
    (select ID from UpdatableTable
    where CONTAINS("indexedcolumns", '{' || Pair.Key || '}') > 0); 

or

update UpdatableTable
  set CLOBColumn = CLOBColumn || b.Value from  (select Key, Value from PairTable) b
  where ID in
    (select ID from UpdatableTable
    where CONTAINS("indexedcolumns", '{' || Pair.Key || '}') > 0); 
于 2013-01-23T14:54:12.193 回答