Tuesday, August 10, 2010

Split a string value into more columns

select
                x[1],x[2]
from (
        select
                    regexp_split_to_array('BeneficaryCurrency=IDR;ExchangeRate=1.000000000;',E'(;*\\w+=|;+)') as x ) t



(or)


select
                split_part(x , '|',1),
                split_part(x , '|',2)
from (
        select
                    regexp_replace('BeneficaryCurrency=IDR;ExchangeRate=1.000000000;', '(\\w+)=([\.|\\w+]+)(\;)', E'\\2|', 'g') as x ) t

No comments:

Post a Comment