List Index Out of Bounds (-1)

Discussion of open issues, suggestions and bugs regarding usage of dbExpress drivers for PostgreSQL in Delphi and C++Builder
Post Reply
Eden0928
Posts: 62
Joined: Sun 22 Apr 2012 14:08

List Index Out of Bounds (-1)

Post by Eden0928 » Thu 16 Jan 2014 07:39

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

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: List Index Out of Bounds (-1)

Post by AlexP » Thu 16 Jan 2014 13:29

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.

Eden0928
Posts: 62
Joined: Sun 22 Apr 2012 14:08

Re: List Index Out of Bounds (-1)

Post by Eden0928 » Thu 16 Jan 2014 15:26

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!

Eden0928
Posts: 62
Joined: Sun 22 Apr 2012 14:08

Re: List Index Out of Bounds (-1)

Post by Eden0928 » Fri 17 Jan 2014 01:54

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?

Eden0928
Posts: 62
Joined: Sun 22 Apr 2012 14:08

Re: List Index Out of Bounds (-1)

Post by Eden0928 » Fri 17 Jan 2014 07:51

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?

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: List Index Out of Bounds (-1)

Post by AlexP » Fri 17 Jan 2014 08:32

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

Eden0928
Posts: 62
Joined: Sun 22 Apr 2012 14:08

Re: List Index Out of Bounds (-1)

Post by Eden0928 » Mon 20 Jan 2014 01:48

I got a solution, maybe. :oops:

When DataSetProvider.Option.poRetainServerOrder set True.

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

But, why?

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: List Index Out of Bounds (-1)

Post by AlexP » Mon 20 Jan 2014 08:20

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.

Post Reply