BML – Solving the array identifier error

2 04 2011

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";
}
}
.....

Advertisement

Actions

Information

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s




Follow

Get every new post delivered to your Inbox.