How do you split a string value in DB2?
For example, given the value:
CHG-FFH.
I want to split on the dash (-), which would resul
If you are sure that each substrings are 3 characters long you can try this code, provided that TABLE1 is a table where there is at least X rows (X = 10 in this example):
select rc, substr(string_to_split, (rc-1)*3+rc, 3) as result from
(select row_number() over() as rc from TABLE1 fetch first 10 rows only) TB_rowcount
cross join
(select 'CHG-FFH' as string_to_split from sysibm.sysdummy1) T2
where substr(string_to_split, (rc-1)*3+rc, 3) <> ' '
If the length of the substrings are not the same you have to apply LOCATE function to find the separator