<?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: Possible Sybase SQL Anywhere bug</title>
	<atom:link href="http://blogs.digitss.com/database/possible-sybase-sql-anywhere-bug/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.digitss.com/database/possible-sybase-sql-anywhere-bug/</link>
	<description>DiGiTSS Team&#039;s Programming experience with PHP, MySQL, Ajax, Javascript, jQuery, C# and Microsoft technologies</description>
	<lastBuildDate>Thu, 04 Mar 2010 12:54:12 +0500</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Dharmavirsinh Jhala</title>
		<link>http://blogs.digitss.com/database/possible-sybase-sql-anywhere-bug/comment-page-1/#comment-10949</link>
		<dc:creator>Dharmavirsinh Jhala</dc:creator>
		<pubDate>Sun, 21 Jun 2009 18:42:35 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.digitss.com/?p=184#comment-10949</guid>
		<description>Here is the reply from official Sybase Support:
-----------------------------------------------
Case/Subcase ID: 11522398

FR: rkwong

Hello Dharmavirsinh

I saw the files and the bug submission and not surprisingly I saw the results. I read your blog entry as well.

You might notice that there is  comment about this issue in your blog. If you are a regular visitor of our SQL Anywhere public blogs and newsgroups you might recognize the name -- Jason is a very experienced member of our company with a lot of experience in SQL Anywhere engineering and product management.

At support I concur with what Jason says. You were making an assumption where TOP or FIRST would sort results in some internal manner even in the absence of an ORDER BY against a field with high granularity.That is not the case.

 If you take a look at your data set, while there is an ORDER BY column, it is on a field with zero granularity (Active is set to &#039;Y&#039; in all rows). Essentially this means if your SELECT statement has the ORDER BY clause on this column it is not sorting anything. In other words, with this particular data set, the ORDER BY active clause does not make a differnce.

We have mentioned in our documentation that the use of top or first without an ORDER BY clause will yield inconsistent results.
See (http://dcx.sybase.com/1101en/dbusage_en11/first-order-formatting.html)
In your case you have an ORDER BY but with zero granularity in your ORDER BY column. With this particular data set you showed us, it acts as if there are no ORDER BY columns and as a consequence, the documented warning about inconsistent results apply.
Best Regards,
Raymond Kwong
iAnywhere Solutions</description>
		<content:encoded><![CDATA[<p>Here is the reply from official Sybase Support:<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
Case/Subcase ID: 11522398</p>
<p>FR: rkwong</p>
<p>Hello Dharmavirsinh</p>
<p>I saw the files and the bug submission and not surprisingly I saw the results. I read your blog entry as well.</p>
<p>You might notice that there is  comment about this issue in your blog. If you are a regular visitor of our SQL Anywhere public blogs and newsgroups you might recognize the name &#8212; Jason is a very experienced member of our company with a lot of experience in SQL Anywhere engineering and product management.</p>
<p>At support I concur with what Jason says. You were making an assumption where TOP or FIRST would sort results in some internal manner even in the absence of an ORDER BY against a field with high granularity.That is not the case.</p>
<p> If you take a look at your data set, while there is an ORDER BY column, it is on a field with zero granularity (Active is set to &#8216;Y&#8217; in all rows). Essentially this means if your SELECT statement has the ORDER BY clause on this column it is not sorting anything. In other words, with this particular data set, the ORDER BY active clause does not make a differnce.</p>
<p>We have mentioned in our documentation that the use of top or first without an ORDER BY clause will yield inconsistent results.<br />
See (http://dcx.sybase.com/1101en/dbusage_en11/first-order-formatting.html)<br />
In your case you have an ORDER BY but with zero granularity in your ORDER BY column. With this particular data set you showed us, it acts as if there are no ORDER BY columns and as a consequence, the documented warning about inconsistent results apply.<br />
Best Regards,<br />
Raymond Kwong<br />
iAnywhere Solutions</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dharmavirsinh Jhala</title>
		<link>http://blogs.digitss.com/database/possible-sybase-sql-anywhere-bug/comment-page-1/#comment-10948</link>
		<dc:creator>Dharmavirsinh Jhala</dc:creator>
		<pubDate>Sun, 21 Jun 2009 18:40:58 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.digitss.com/?p=184#comment-10948</guid>
		<description>Thanks Jason,
I highly appreciate your effort for taking a time to reply to my query.

I understand what you are trying to explain.</description>
		<content:encoded><![CDATA[<p>Thanks Jason,<br />
I highly appreciate your effort for taking a time to reply to my query.</p>
<p>I understand what you are trying to explain.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jason Hinsperger</title>
		<link>http://blogs.digitss.com/database/possible-sybase-sql-anywhere-bug/comment-page-1/#comment-10682</link>
		<dc:creator>Jason Hinsperger</dc:creator>
		<pubDate>Mon, 13 Apr 2009 15:46:36 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.digitss.com/?p=184#comment-10682</guid>
		<description>I expect that support will tell you that your query: 
SELECT top 5 start at 6 id,first_name,last_name,active FROM contacts ORDER BY active;
makes an assumption that the database server always returns/processes data in a certain order (by contacts.id).  This assumption, though it may work some of the time, is false (and is false for most, if not all RDBMS&#039;s).

Unless you are explicit in the query, the server is free to process/return rows in whatever order it deems optimal.  In fact, the query above may even return different result sets if run multiple times in succession or under different server loads.

Your &#039;workaround&#039; query is actually the correct way to write the query to get the results you want.  You need to explicitly tell the server that want the data ordered by the id field when determining what to return.</description>
		<content:encoded><![CDATA[<p>I expect that support will tell you that your query:<br />
SELECT top 5 start at 6 id,first_name,last_name,active FROM contacts ORDER BY active;<br />
makes an assumption that the database server always returns/processes data in a certain order (by contacts.id).  This assumption, though it may work some of the time, is false (and is false for most, if not all RDBMS&#8217;s).</p>
<p>Unless you are explicit in the query, the server is free to process/return rows in whatever order it deems optimal.  In fact, the query above may even return different result sets if run multiple times in succession or under different server loads.</p>
<p>Your &#8216;workaround&#8217; query is actually the correct way to write the query to get the results you want.  You need to explicitly tell the server that want the data ordered by the id field when determining what to return.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dharmavirsinh Jhala</title>
		<link>http://blogs.digitss.com/database/possible-sybase-sql-anywhere-bug/comment-page-1/#comment-10663</link>
		<dc:creator>Dharmavirsinh Jhala</dc:creator>
		<pubDate>Sun, 12 Apr 2009 15:24:32 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.digitss.com/?p=184#comment-10663</guid>
		<description>Now I have reported this bug (#11522398), let&#039;s see what is their answer. Will keep updates posted on this.</description>
		<content:encoded><![CDATA[<p>Now I have reported this bug (#11522398), let&#8217;s see what is their answer. Will keep updates posted on this.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
