strtok for Teradata 13

Database

strtok for Teradata 13

Hi,

Need to split the column value onto separate variable columns or rows

eg:

1|B|CDE|F|

2|A|

3|A|B|C|

Need to split the '|' delimited values onto separate subtrsings and process accordingly. The number of '|' can vary.

Tags (1)
2 REPLIES
Teradata Employee

Re: strtok for Teradata 13

You can try on this way

create volatile table MyTest
(
clave integer,
chorizo varchar(1000)
)primary index( clave )
on commit preserve rows;

insert into MyTest(1, 'Calle~General Mola~28057');
insert into MyTest(2, 'AvenidaValgame Dios11428058');
insert into MyTest(3, 'Travesía~Gaztambide~0~28059');
insert into MyTest(4, 'Calle~Toma Moreno~4~28056');
insert into MyTest(5, 'Calle~Ansia viva~9~28122');
insert into MyTest(6, 'Calle~Percebe~66~28265');

SELECT *
FROM TABLE (STRTOK_SPLIT_TO_TABLE(MyTest.clave, MyTest.chorizo, '~')
RETURNS (outkey INTEGER,
tokennum INTEGER,
token VARCHAR(128) CHARACTER SET UNICODE)
) AS d
order by 1, 2
New Member

Re: strtok for Teradata 13

my understanding is that strtok_split_to_table function only works on TD 14+ versions, here we're asking for a method for TD 13..