This Friday’s function is a simple utility to determine whether a column exists in a table.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
Column Exists = Function({dt,colName},{Default Local}, Try( lstNames = dt << Get Column Names(string); pos = Loc(lstNames,colName); If (NRows(pos)==0, retVal = 0 , retVal = 1 ) , retVal = 0 ); Return(retVal) ); |
Typically I use this in conjunction with an Assert function:
1 2 3 |
Assert( Column Exists(dt,col), "Column Not Found" ); |
Tackar så mycket för webbplatsen det hjälpmedel en hel del.