sql - parse and replace in oracle -


i new sql/oracle, , wondering if there's easy way parse csv string , replace tokens string.

for example, have string like

param,value1,str1,param,value2,str3,param,value3

and want replace value after param constant

so, string become

param,constant,str1,param,constant,str3,param,constant

thanks in advance.

you can try regexp_replace

select regexp_replace(regexp_replace(regexp_replace(            str,'[^,]*','constant',1,3),'[^,]*','constant',1,9),'[^,]*','constant',1,15)    (select 'param,value1,str1,param,value2,str3,param,value3' str dual); 

if have messy (like quoted values including commas) break. said regular expressions aren't strong point , should eb able better job.

i presume know having rdbms oracle , storing data in such odd manner pretty poor idea. if not going convetional table/column structure, can use object relation features or xml.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -