Hello,
I'm trying to update one data table with columns from another table, using matching columns criteria defined by a string.
In the example below, dt1 is my main table, and dt2 is a sort of config file containing the column to add (i.e. "ROUTE"), while all other columns are used in matching to dt1. Since dt2 is user-defined, I can't know these other column names ahead of time, hence the need to use a formatted string:
// define string for column matching
textinp = "";
matchCols = dt2 << get column names(string);
// remove "ROUTE" from dt2 column name list
for (i = nitems(matchCols), i > 0, i--,
if (contains(matchCols, "ROUTE"), remove from(matchCols, i));
);
// create string for column matching
for (i=1, i<=nitems(matchCols), i++,
textinp = concat(textinp,":",matchCols," = :",matchCols,", ");
);
textinp = left(textinp,length(textinp)-2);
print(textinp);
// update dt1
dt1 << Update(
With( dt2 ),
Match Columns(
parse(textinp)
)
);
Parsing textinp to the update command produces this error (the string is produced correctly as seen in the first line):
":X = :X, :Y = :Y"
Unexpected ",". Perhaps there is a missing ";" or ",".
Line 1 Column 8: :X = :X►, :Y = :Y
As far as I know there shouldn't be any problem separating multiple columns with commas inside match columns(), and in fact when I try to define it literally, i.e.:
// update dt1
dt1 << Update(
With( dt2 ),
Match Columns(
:X = :X, :Y = :Y
)
);
It works perfectly fine. Any idea why it can't handle / parse the string? Your help is greatly appreciated!