After doing a BMQL or getpartsdata() in BML, doing a for loop for validating something on the records often would cause some errors. For example,
tableResults = bmql("SELECT SelectColumn FROM DataTable WHERE WhereColumn1=$WhereAttribute and WhereColumn2=$Variable");
for result in tableResults {
if (ConditionAttribute == result[0]) {
resultVariable = result[0];
break;
}
else {
resultVariable = "StaticValue";
}
}.....
The above rule, eventhough it looks perfectly alright, BML engine throws errors like “result in line x is not a valid array identifier”. I’ve realized that we cannot directly associate the record value to a condition attribute in a for loop of table results. If it was getpartsdata(), then we could declare the ‘SelectColumn’ as a string field and solve this array identifier error. But in BMQL, we don’t have the flexibility of declaring a table column in the rule.
So, i figured out if we return the coluimn values to a variable by ‘get’ function, this would solve the issue.
GetVariable=get(result,"SelectColumn");
Hence the modified script would be
tableResults = bmql("SELECT SelectColumn FROM DataTable WHERE WhereColumn1=$WhereAttribute and WhereColumn2=$Variable");
for result in tableResults {
GetVariable=get(result,"SelectColumn");
if (ConditionAttribute == GetVariable) {
resultVariable = GetVariable;
break;
}
else {
resultVariable = "StaticValue";
}
}
.....





