Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I query blank fields (to restructure a table to eliminate them)

Status
Not open for further replies.

Pharmer

Technical User
Aug 15, 2002
13
0
0
US
I have been importing a text file which yields a table with 64 fields. Many of these fields are blank, and I can change the source generator to eliminate these fields, but I need to find which fields are absolutely blank so that I can redo the source material & restructure the resulting table. There must be an easier way than querying "BLANK" on each field.

Thank you

Douglas Ellis
 
Douglas,

Well, if you don't mind using a little bit of ObjectPAL, you can use a tCursor and cCount() to determine the count of non-blank values in each field of your table. For example, this shows an array of the fields in a table and the number of non-blank values:

Code:
method pushButton(var eventInfo Event)
var
   tc   TCursor
   astr Array[] String
   si   SmallInt
endVar

   if isBlankZero() then
      BlankAsZero( No )
   endIf
   tc.open( "xtabdata" )
   for si from 1 to tc.nFields()
      astr.addLast( tc.fieldName( si ) + ": " +
                    string( tc.cCount( si ) ) )
   endFor
   astr.View( "cCount" )

endMethod

It's crude, but you could rework it to test the result of cCount for 0 and, if true, then add that field to the array. That done, the final display would show you only fields that are blank.

TCursors based solutions are frequently faster than query based ones.

And, yes, BlankAsZero needs to be off for this to work properly; otherwise your blank numeric fields will be interpreted as having values of zero.

Hope this helps...

-- Lance
 
The code display the information in an array (works well), but I need to apply the change (viz. restructure table to eliminate blank fields). How do I do it, either the restructure or printing the array contents?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top