2014/01/17

DBCommon.pas 雖然有 BUG ,但裡頭值得研究

此單元可以分析SQL語句,提供對於SQL 語句的TOKEN方式的解析。提供TExprParser,分析了類。
SQL Parser in Delphi for SQL Server

很開心的,我遇到這個問題……
DBCommon.GetIndexForOrderBy Get ERROR
List Index Out of Bounds (-1)

簡單的說就是:
如果 Order 後面接了一些內容 (EX: LIMIT),而該 SQL 語句也沒有回傳值(RecordCount = 0)時,就會發生錯誤。

仿間的解決方法 Can I recompile the .PAS files used by the Delphi IDE?

2014/01/20 更新
在這篇文章中,有個出乎意料的解法:
dbExpress + InterBase and ORDER BY
Datasnap.Provider.TProviderOptions 

  DataSetProvider.Options.poRetainServerOrder := True;

這樣就能夠解決 GetIndexForOrderBy 在特殊情況下會出錯的問題。

只是為什麼要這樣設定?
EMBT 沒說清楚,論壇上也沒講明白。

2014/01/21 更新
針對 poRetainServerOrder 設定項, Devart 論壇的回覆是這樣的:
This behavior is due to the fact that, when setting the poRetainServerOrder option to True, sorting on the client side doesn't occur, the sorting returned by the server is used.

那麼,這個錯誤真的算是 "Bug" 嗎?
按照 2004 年的 Borland 論壇,某位 Delphi 狂熱者是這麼說的:
Therefore there is no bug, it is as designed, and there are two documented
ways of dealing with the situation.


是 Bug 還是 Feature?就交給在座前的各位看倌評判囉!

2015/07/02 更新
poRetainServerOrder 的影響 :
在導出 MyBase XML,裡面的 PARAMS 段如下:
 

DEFAULT_ORDER 的值由左到右標明 Field 為排序的順位
這個 Index 用到的機會很小,幾乎也沒有人在用
因為!只有搭配【DBX】時才會產生,如果沒有這「Feature」,還真不知道會有這個問題。

沒有留言:

張貼留言