By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
create function formatted(n varchar(17))
returns varchar(21)
begin
return concat(
substring(n, 1, 4),
'-',
substring(n, 5, 4),
'-',
substring(n, 9, 4),
'-',
substring(n, 13, 4),
'-',
substring(n, 17, 1)
);
end;
//
create table t (f varchar(21));
insert into t (f) values (formatted('12345678901234567'));
select * from t;
f |
---|
1234-5678-9012-3456-7 |