¿Por qué no usar simplemente substr()
? ?
select t.*, to_number(substr(element_id, 3, 2)) as my_seq
from t;
Un segundo enfoque es usar dense_rank()
:
select t.*,
dense_rank() over (partition by u_a_id order by substr(element_id, 1, 4)) as my_seq
from t;
Puedes usar merge
si realmente desea actualizar los datos:
merge into t using
(select t.*,
dense_rank() over (partition by u_a_id order by substr(element_id, 1, 4)) as new_my_seq
from t
) s
on s.u_a_id = t.u_a_id and s.element_id = st.element_id
when matched then update
set t.my_seq = s.new_my_seq;