开发者

Update Clob column in Oracle

I have an table with name ABC which has CLOB data. I want to update the column to insert string in specific position in this Clob column.

String to be inserted :

<nv_pair>
<name identifier="XYZ"></name>
<value identifier="XYZ"></value>
</nv_pair>

Cl开发者_如何学JAVAob Data :

<form> <nv_pair></nv_pair> <nv_pair></nv_pair><nv_pair></nv_pair><nv_pair></nv_pair></form>

Position to be inserted : Just Before </form>


Take a look at DBMS_LOB package.

BTW, it might be worth exploring the possibility of abandoning CLOB and using Oracle's built-in XML capabilities (I'm not familiar with that, though).


Depending on which version of Oracle you have, you can use the regexp_replace function:

update abc
set clob_val =
  regexp_replace(clob_val,
                 '^(.+)(</form>)',
                 '\1<nv_pair><name identifier="XYZ"></name><value identifier="XYZ">/value>/nv_pair>\2')
where ...
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜