Można to zrobić mały trick: najpierw zastępując wszystkie przecinki przecinkiem, po którym następuje spacja, a następnie pomiń dodatkową przestrzeń wiodącą:
SQL> with data as
2 (select '100016154,5101884LT00001,,,,,100000010892100000012655,L,SEI,5101884LT00001,1,SL,3595.03,00,2,N,N,G,N' txt
3 from dual
4 )
5 select regexp_substr(txt,'[^,]+',1,7) seventh_element_wrong
6 , replace(txt,',',', ') with_extra_space_after_comma
7 , regexp_substr(replace(txt,',',', '),'[^,]+',1,7) seventh_element_leading_space
8 , substr(regexp_substr(replace(txt,',',', '),'[^,]+',1,7),2) the_seventh_element
9 from data
10/
S WITH_EXTRA_SPACE_AFTER_COMMA
- ----------------------------------------------------------------------------------------------------------------------
SEVENTH_ELEMENT_LEADING_S THE_SEVENTH_ELEMENT
------------------------- ------------------------
1 100016154, 5101884LT00001, , , , , 100000010892100000012655, L, SEI, 5101884LT00001, 1, SL, 3595.03, 00, 2, N, N, G, N
100000010892100000012655 100000010892100000012655
Regar ds,
Rob.
Gdy zobaczysz CSV lub inne wartości serializowane w RDBMS, wiesz, że coś jest nie tak. – NullUserException
@NullUserException, dobry punkt. Niestety natknąłem się na to zbyt wiele razy :-( – Ollie