I am trying to parse a string. I am quering a field called ACCOUNT_CODE from a table called PO_ACCOUNT.
Each account code has 7 segment names and each segment is divided by the tilda symbol:
INDEX~OBJ~USR~GRANTCD~GRANTDTL~PROJCD~PROJDTL
Not all segments are required so the data in the field could be completely populated like:
DV709790~0654~956~100~225863~899045~0097611
Or only partially populated like:
DV709790~0654~956~100~ ~ ~
I need to query this data and so that each segment is it's own column name. Each segment varies in length (from 3 to 6 in length) making it impossible to use standard LEFT or RIGHT functions.
My SQL is not good enough yet to understand how to grab all seven segments and query from the table. Any input is greatly appreciated!
Each account code has 7 segment names and each segment is divided by the tilda symbol:
INDEX~OBJ~USR~GRANTCD~GRANTDTL~PROJCD~PROJDTL
Not all segments are required so the data in the field could be completely populated like:
DV709790~0654~956~100~225863~899045~0097611
Or only partially populated like:
DV709790~0654~956~100~ ~ ~
I need to query this data and so that each segment is it's own column name. Each segment varies in length (from 3 to 6 in length) making it impossible to use standard LEFT or RIGHT functions.
My SQL is not good enough yet to understand how to grab all seven segments and query from the table. Any input is greatly appreciated!