![]() www.fireflysoftware.com |
Cull Unused DB Table Fields |
|
|
|
|
This example demonstrates the technique of returning only those items in a formatted list that are contained in a simple list of names. For example, suppose you have a database table's structure formatted as field name, type, size and description:
Now suppose the table structure is rather lengthy, containing 200 or more fields making it impossible to handle without some sort of automation. Of those 200 fields, only about 50 are actually used and by whatever means, you happen to have a list of all 50 or so used fields. For sake of demonstration we'll represent this set of used fields by the following short list of field names:
Now, say you'd like to reduce the formatted list so that it contains only the 50 or so fields which are actually in-use. How do you do this? Simple. Since you have a list of the 50 or so fields that are in actual use, you merely combine both lists, sort them together and using the OutDuplLines filter, you output all duplicates according to the field names only. Then, you get rid of the lines containing only the field names and you're done! Pretty simple using English as a programming language, huh? Fortunately it's not much more difficult using TEXTools. Again, starting with a combined list, we sort it using the SortLines filter:
Executing this one-filter pipe gives us:
Next, we add two more filters to the pipe: the PadLinesRight filter to pad the lines to a minimum width of 14 characters and the OutDuplLines filter to output only those lines that are duplicated according to character columns 1 to 14:
The pipe's execution now gives us the following output:
Now, to get rid of the lines with only a field name, we add the JoinLines filter to join every two lines onto a single line:
This results in the following:
Finally, we add the DelChars filter to our pipe to delete the first 14 characters thereby getting rid of the redundant field names:
Execution of this pipe results in the desired output:
An alternative approach to getting rid of the redundant field names is demonstrated by the following pipe which pads the lines with asterisks (*) to character column 15 and then removes those lines with an asterisk in column 15:
|
|
|
[Home] [Contact Us] [Downloads] [Purchase/Register] |
|
|
Copyright © 2005 Firefly Software |
|