I have a VARCHAR
column that contains 5 informations (2 CHAR(3)
and 3 TIMESTAMP
) separated with '$
'.
CREATE TABLE MYTABLE (
COL VARCHAR(256) NOT NULL
);
INSERT INTO MYTABLE
VALUES
( 'AAA$000$2009-10-10 10:50:00$null$null$null' ),
( 'AAB$020$2007-04-10 10:50:00$null$null$null' ),
( 'AAC$780$null$2007-04-10 10:50:00$2009-04-10 10:50:00$null' )
;
I would like to extract the 4th field ...
'AAA$000$2009-10-10 10:50:00$null$null$null'
^^^^ this field
... to have something like
SELECT SPLIT(COL, '$', 4) FROM MYTABLE
1
-----
'null'
'null'
'2009-04-10 10:50:00'
I'm searching, in that order :
- A DB2 build-in string function
- An embeddable statement such as
SUBSTR(COL, POSSTR(COL)+1)...
- An user defined function that behaves like
SPLIT
Precision : Yes, I do know that it's not a good idea to have such columns...