Skip to main content
Announcements
July 15, NEW Customer Portal: Initial launch will improve how you submit Support Cases. READ MORE

When a table contains more than what is needed (i.e. only valued fields)

cancel
Showing results for 
Search instead for 
Did you mean: 
Marco_Imperiale
Contributor III
Contributor III

When a table contains more than what is needed (i.e. only valued fields)

Last Update:

May 30, 2024 8:39:28 AM

Updated By:

Marco_Imperiale

Created date:

May 30, 2024 8:39:28 AM

Hi,
have you ever needed to delete the fields of a table with hundreds of columns that were actually unused (i.e., empty or zero)?
Here is the function that will INSTANTLY allow you to remove the columns without values:

sub ClearFields(tName)  //pass the table name AFTER a Load *...
    let cancellati=0;
    let totfield=NoOfFields('$(tName)');
    let vElenco='';
    
    for i=0 to totfield
        let vFName = PurgeChar(FieldName($(i),'$(tName)'),'[]"');
        let vCnt=FieldValueCount('$(vFName)');
        if vCnt=1 then
            vElenco = vElenco & ',[$(vFName)]';
            let cancellati=cancellati+1;
        end if
    next i

    if cancellati>0 then
       vElenco = mid(vElenco,2);
       drop fields $(vElenco) from $(tName);
       trace Tabella $(tName): cancellati $(cancellati) campi su $(totfield) iniziali presenti;
    else
       trace Table $(tName): nessun campo eliminato su $(totfield);
    end if
end sub
Labels (2)
Contributors
Version history
Last update:
‎2024-05-30 08:39 AM
Updated by: