<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Tucker Watson&#187; BQL</title>
	<atom:link href="http://tuckwat.com/blog/tag/bql/feed/" rel="self" type="application/rss+xml" />
	<link>http://tuckwat.com/blog</link>
	<description>Software development - Flex, Niagara AX, oBIX, and more</description>
	<lastBuildDate>Fri, 05 Nov 2010 12:20:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>BQL Query to array of BObjects</title>
		<link>http://tuckwat.com/blog/niagara-ax/bql-query-array-bobjects/</link>
		<comments>http://tuckwat.com/blog/niagara-ax/bql-query-array-bobjects/#comments</comments>
		<pubDate>Wed, 11 Feb 2009 03:52:15 +0000</pubDate>
		<dc:creator>Tucker</dc:creator>
				<category><![CDATA[Niagara]]></category>
		<category><![CDATA[BQL]]></category>

		<guid isPermaLink="false">http://tuckwat.com/blog/?p=170</guid>
		<description><![CDATA[Sometimes the batch editor doesn&#8217;t cut it and I&#8217;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 [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes the batch editor doesn&#8217;t cut it and I&#8217;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.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> BObject<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> getObjectsFromBql<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> bqlString<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
   BOrd curOrd<span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #666666; font-style: italic;">// Grab reference to local station</span>
   BStation station <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>BStation<span style="color: #009900;">&#41;</span> BOrd.<span style="color: #006633;">make</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;station:|slot:/&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #666666; font-style: italic;">// Run the BQL query and get the resulting table</span>
   BITable result <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>BITable<span style="color: #009900;">&#41;</span> BOrd.<span style="color: #006633;">make</span><span style="color: #009900;">&#40;</span>bqlString<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>station<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
   ColumnList columns <span style="color: #339933;">=</span> result.<span style="color: #006633;">getColumns</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   TableCursor c <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>TableCursor<span style="color: #009900;">&#41;</span> result.<span style="color: #006633;">cursor</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #666666; font-style: italic;">// Create the Array of BObjects to return</span>
   BObject<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> objs <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> BObject<span style="color: #009900;">&#91;</span>result.<span style="color: #006633;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span>c.<span style="color: #006633;">next</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
   <span style="color: #009900;">&#123;</span>
      objs<span style="color: #009900;">&#91;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> c.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
   <span style="color: #000000; font-weight: bold;">return</span> objs<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<h3>Example to get an Array of all BStatusNumerics in &#8216;fault&#8217;: </h3>
<p><code><br />
getObjectsFromBql("select * from baja:StatusNumeric where status.isFault")<br />
</code></p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://tuckwat.com/blog/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://tuckwat.com/blog/niagara-ax/bql-query-array-bobjects/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>BQL Demystified &#8211; Part II</title>
		<link>http://tuckwat.com/blog/niagara-ax/bql-demystified-part-ii/</link>
		<comments>http://tuckwat.com/blog/niagara-ax/bql-demystified-part-ii/#comments</comments>
		<pubDate>Sat, 07 Feb 2009 18:04:36 +0000</pubDate>
		<dc:creator>Tucker</dc:creator>
				<category><![CDATA[Niagara]]></category>
		<category><![CDATA[AX]]></category>
		<category><![CDATA[BQL]]></category>

		<guid isPermaLink="false">http://tuckwat.com/blog/?p=70</guid>
		<description><![CDATA[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 &#8211; Part I that covers basic syntax and meaning. This post will extend John&#8217;s post by demonstrating the Query Builder, running custom queries, and other examples. The example we&#8217;re going [...]]]></description>
			<content:encoded><![CDATA[<p>One of the most powerful but underutilized features of Niagara AX is BQL queries.  John Sublett wrote an excellent post on Niagara-Central called <a href="http://www.niagara-central.com/ord?portal:/blog/BlogEntry/103">BQL Demystified &#8211; Part I</a> that covers basic syntax and meaning.  This post will extend John&#8217;s post by demonstrating the Query Builder, running custom queries, and other examples.</p>
<p>The example we&#8217;re going to try is how to view the name of all Numeric Points whose name starts with &#8220;SpaceTemp&#8221;. Open the Query Builder (File&gt;Open&gt;Query Builder) and configure it as shown below.</p>
<div id="attachment_78" class="wp-caption aligncenter" style="width: 560px"><img class="size-full wp-image-78" title="Query Builder Example" src="http://tuckwat.com/blog/wp-content/uploads/2009/02/querybuilder1.png" alt="Example of input data for a Niagara AX BQL Query" width="550" height="217" /><p class="wp-caption-text">Example of input data for a Niagara AX BQL Query</p></div>
<p>After pressing <em>OK</em> you&#8217;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:</p>
<p style="text-align: center;"><code>station:|slot:/|bql:select navOrd from control:NumericPoint where name = 'SpaceTemp'</code></p>
<p style="text-align: left;">The cool part is that you can write and run your own query by copying it into the <em>Open Ord</em> dialog (CTRL+L).</p>
<h3 style="text-align: left;">More Examples:</h3>
<div class="other">
<h5 style="text-align: left;">View all Numeric Points whose name contains the word &#8220;Outside&#8221;:</h5>
<p style="text-align: left;"><code>station:|slot:/|bql:select * from control:NumericPoint where name like '*Outside*'</code></p>
<h5 style="text-align: left;">View the ord of all Numeric Points that are &gt; 85:</h5>
<p style="text-align: left;"><code>station:|slot:/|bql:select slotPath from control:NumericPoint where out.value &gt; 85.0</code></p>
<h5 style="text-align: left;">View the name and ord of all Control Points whose status is not OK:</h5>
<p style="text-align: left;"><code>station:|slot:/|bql:select navName,ord from control:ControlPoint where !status.isOk </code></p>
</div>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://tuckwat.com/blog/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://tuckwat.com/blog/niagara-ax/bql-demystified-part-ii/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

