I have a some json configuration in the table something like below
create table X (name varchar, config json);
insert into X (name, config) values (
'name1',
'{"method":"XYZ","frequent":["MONTHLY","WEEKLY"]}'
);
insert into X (name, config) values (
'name2',
'{"method":"ABC","frequent":["WEEKLY", "DAILY"]}'
);
Basically this frequent property in json column can contain any number of elements as this is an array.
Now I want to modify all the records in a table where "frequent":["MONTHLY", "WEEKLY"] to "frequency":["P1M","P1W"] and so on..
So output should be something like that
'name1','{"method":"XYZ","frequency":["P1M","P1W"]}'
'name2','{"method":"ABC","frequency":["P1W","P1D"]}'
Should I go with CASE WHEN and THEN approach or is there any better way to do that?
version : 9.5+