Using a template in an update?
3 answers
You may be looking for a feature REGEXP_REPLACE
and REGEXP_LIKE
in combination with an update.
update sometable set somecol = REGEXP_REPLACE(somecol, ...) where REGEXP_LIKE(somecol, ...)
+6
a source to share
The values ββthat will be used in the update are displayed here. The where clause ensures that notify4-11 remains unchanged.
create table notify(n varchar(20));
insert into notify(n) values('notify4-0');
insert into notify(n) values('notify4-1');
insert into notify(n) values('notify4-2');
insert into notify(n) values('notify4-8');
insert into notify(n) values('notify4-9');
insert into notify(n) values('notify4-11');
select n, regexp_replace(n,'^notify4-([1-9]{1})$', 'notify5-\1') from notify where regexp_like(n, '^notify4-[1-9]{1}$') order by n;
+2
a source to share