Parsing text fields
18 January, 2010
An example of the text is:
[quote]218Vivotech:StoreInfo227Insomnia 20 Upper Baggot St219Vivotech:TerminalId2167000000000003362224Vivotech:TransactionType214Loyalty Earned[/quote]
From which I would parse out StoreInfo, TerminalId and TransactionType.
Do you think it is worth attempting this using Freehand SQL within Yellowfin or in the DB itself? I would prefer within Yellowfin myself.
Having said that, it should be possible to extract data from this field if you know the order of the fields. The sql functions to do this will depend on which database you are using. For MS SQL Server you can use the SUBSTRING function. Assuming that the fields are of variable length, you will also need to find the start and end index of the field within the string using CHARINDEX.
An example to retrieve the second token:
[quote]SUBSTRING(TextField, CHARINDEX(':', TextField) + 1, CHARINDEX(':', TextField, CHARINDEX(':', TextField) + 1) - CHARINDEX(':', TextField) - 1)[/quote]
As you can see, this is already fairly complicated. If you have a variable number of fields, or you aren't sure of the location of the fields within the string, it will be even more difficult.