<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: While select firstonly</title>
	<atom:link href="http://www.artofcreation.be/2009/10/22/while-select-firstonly/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.artofcreation.be/2009/10/22/while-select-firstonly/</link>
	<description>The everyday life of a Dynamics AX developer</description>
	<lastBuildDate>Mon, 26 Jul 2010 20:09:49 +0200</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: Malcolm Burtt</title>
		<link>http://www.artofcreation.be/2009/10/22/while-select-firstonly/comment-page-1/#comment-1597</link>
		<dc:creator>Malcolm Burtt</dc:creator>
		<pubDate>Wed, 09 Dec 2009 11:38:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.artofcreation.be/?p=268#comment-1597</guid>
		<description>I think that the reason that they say not to use &quot;while select firstOnly&quot; stems from the note that appears alongside the X++ best practice advice about using &quot;select firstOnly&quot;. It says...

&quot;The firstOnly qualifier does not guarantee that only one record is returned.&quot;

and then this is immediately followed by the statement...

&quot;Do not use while select firstOnly.&quot;

...the two things are linked.

If you use &quot;while select firstOnly&quot; you may write code that assumes that only one record will be processed by the while loop (i.e. that there will be only one iteration and that the loop will immediately exit after that one iteration). In fact there is no way to be sure that only one iteration will occur. Even if you write your code knowing that more than one iteration might occur someone else might later make the mistake of assuming firstOnly means just one iteration.</description>
		<content:encoded><![CDATA[<p>I think that the reason that they say not to use &#8220;while select firstOnly&#8221; stems from the note that appears alongside the X++ best practice advice about using &#8220;select firstOnly&#8221;. It says&#8230;</p>
<p>&#8220;The firstOnly qualifier does not guarantee that only one record is returned.&#8221;</p>
<p>and then this is immediately followed by the statement&#8230;</p>
<p>&#8220;Do not use while select firstOnly.&#8221;</p>
<p>&#8230;the two things are linked.</p>
<p>If you use &#8220;while select firstOnly&#8221; you may write code that assumes that only one record will be processed by the while loop (i.e. that there will be only one iteration and that the loop will immediately exit after that one iteration). In fact there is no way to be sure that only one iteration will occur. Even if you write your code knowing that more than one iteration might occur someone else might later make the mistake of assuming firstOnly means just one iteration.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Luegisdorf</title>
		<link>http://www.artofcreation.be/2009/10/22/while-select-firstonly/comment-page-1/#comment-1432</link>
		<dc:creator>Luegisdorf</dc:creator>
		<pubDate>Thu, 19 Nov 2009 19:09:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.artofcreation.be/?p=268#comment-1432</guid>
		<description>Hi Klaas

I think, the capital reason why best practice does deny the use of &#039;while select firstonly&#039; is the readablity. I don&#039;t think it&#039;s a performance issue.

But I like the idea to have the exists condition for free as you have discovered.

I just would recommend to comment that statement to make clear what the meaning of the code was, like:

// find firstonly and do some stuff if found
while select firstonly myTable
{
    doTheStuff();
}

Thank you for this article and
best regards
Patrick</description>
		<content:encoded><![CDATA[<p>Hi Klaas</p>
<p>I think, the capital reason why best practice does deny the use of &#8216;while select firstonly&#8217; is the readablity. I don&#8217;t think it&#8217;s a performance issue.</p>
<p>But I like the idea to have the exists condition for free as you have discovered.</p>
<p>I just would recommend to comment that statement to make clear what the meaning of the code was, like:</p>
<p>// find firstonly and do some stuff if found<br />
while select firstonly myTable<br />
{<br />
    doTheStuff();<br />
}</p>
<p>Thank you for this article and<br />
best regards<br />
Patrick</p>
]]></content:encoded>
	</item>
</channel>
</rss>
