Sometimes the batch editor doesn’t cut it and I’m required to write a program to interact with a certain type of component. I could write a robot to traverse through the nav tree but I usually use a BQL query to do the work. The following is a method I often use to grab an Array of BObjects for a given BQL query.
public BObject[] getObjectsFromBql(String bqlString)
{
BOrd curOrd;
// Grab reference to local station
BStation station = (BStation) BOrd.make("station:|slot:/").get();
// Run the BQL query and get the resulting table
BITable result = (BITable) BOrd.make(bqlString).get(station);
ColumnList columns = result.getColumns();
// Note we're assuming column 0 is "slotPath"
Column slotPathColumn = columns.get(0);
TableCursor c = (TableCursor) result.cursor();
// Create the Array of BObjects to return
BObject[] objs = new BObject[result.size()];
int i = 0;
while (c.next())
{
curOrd = BOrd.make(c.get(slotPathColumn).toString());
// Resolve each ord to a BObject, store in our Array
objs[i++] = (BObject)curOrd.resolve(station).get();
}
return objs;
}
Example to get an Array of all BStatusNumerics in ‘fault’:
getObjectsFromBql("select slotPath from baja:StatusNumeric where status.isFault")
Note: You must specify ’slotPath’ as the first column in the query
Tucker Niagara BQL, Niagara
One of the most powerful but underutilized features of Niagara AX is BQL queries. John Sublett wrote an excellent post on Niagara-Central called BQL Demystified - Part I that covers basic syntax and meaning. This post will extend John’s post by demonstrating the Query Builder, running custom queries, and other examples.
The example we’re going to try is how to view the name of all Numeric Points whose name starts with “SpaceTemp”. Open the Query Builder (File>Open>Query Builder) and configure it as shown below.

Example of input data for a Niagara AX BQL Query
After pressing OK you’ll get a table wtih the resulting query. To view the generated query, hold CTRL and press L (this shows your current ORD). You should see somethign similar to this:
station:|slot:/|bql:select navOrd from control:NumericPoint where name = 'SpaceTemp'
The cool part is that you can write and run your own query by copying it into the Open Ord dialog (CTRL+L).
More Examples:
View all Numeric Points whose name contains the word “Outside”:
station:|slot:/|bql:select * from control:NumericPoint where name like '*Outside*'
View the ord of all Numeric Points that are > 85:
station:|slot:/|bql:select slotPath from control:NumericPoint where out.value > 85.0
View the name and ord of all Control Points whose status is not OK:
station:|slot:/|bql:select navName,ord from control:ControlPoint where !status.isOk
Tucker Niagara AX, BQL, Niagara