Page 1 of 1

List Index Out of Bounds (-1)

Posted: Thu 16 Jan 2014 07:39
by Eden0928
My SQLQuery.CommandText is :

Code: Select all

SELECT * FROM m_book WHERE 1=1 ORDER BY m_book.ISBN LIMIT 0
But, I get the Error msg: List Index Out of Bounds (-1) when ClientDataSet1.Open.

Why?

Delphi XE 15.0.3953.35171
dbExpress for PostgreSQL V3.3.4.0

Re: List Index Out of Bounds (-1)

Posted: Thu 16 Jan 2014 13:29
by AlexP
Hello,

This problem is due to the standard DBCommon.GetIndexForOrderBy method, and the parser doesn't take into account the necessity of comma between columns in the OrderBy section, since everything, that is after OrderBy in the parser is defined as fields, and when attempting to find a field by the 0 index, when calling

Code: Select all

LastField := DataSet.Fields[FieldIndex - 1].FieldName 
(in this case, FieldIndex = 0), you get a corresponding error. You can report this problem to the RAD Studio developers.

Re: List Index Out of Bounds (-1)

Posted: Thu 16 Jan 2014 15:26
by Eden0928
Thank you!

I have reporting this problem to EMBT QC.
http://qc.embarcadero.com/wc/qcmain.aspx?d=121795

If necessary, please add content. Thank you!

Re: List Index Out of Bounds (-1)

Posted: Fri 17 Jan 2014 01:54
by Eden0928
I try pgDAC.
It can work!!!
No Error Msg!

So, It's DBX bug...?

Could you help me change license to pgDAC from dbexpress for PostgreSQL?

Re: List Index Out of Bounds (-1)

Posted: Fri 17 Jan 2014 07:51
by Eden0928
I try the Embarcadero's dbexpress for SQL SERVER

Code: Select all

SELECT top 0 * FROM book WHERE 1=1 ORDER BY book.ISBN
It's work, correct!
No any error message, too.

Why?

Re: List Index Out of Bounds (-1)

Posted: Fri 17 Jan 2014 08:32
by AlexP
Hello,

This problem occurs only in dbExpress when using the LIMIT construct (or any other, that follows ORDER BY). Since in the SQL Server query you are using a "clean" ORDER BY, so the problem doesn't occur.

P.S. Concerning license shift, you can contact our Sales department at sales*devart*com

Re: List Index Out of Bounds (-1)

Posted: Mon 20 Jan 2014 01:48
by Eden0928
I got a solution, maybe. :oops:

When DataSetProvider.Option.poRetainServerOrder set True.

This code: "ORDER BY field LIMIT 0" can correct work!

But, why?

Re: List Index Out of Bounds (-1)

Posted: Mon 20 Jan 2014 08:20
by AlexP
Hello,

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.