Page 1 of 1

Error using limit and offset

Posted: Wed 16 Oct 2013 15:44
by luizcapu
Hi !

I need to use limit and offset in my query but it raises an exception when I call Query.Open. I'm using native TSQLConnection with native TSQLQuery from Delphi XE2 with devart postgresql driver.

I already tested the SQL without limit and offset statments and it works fine.

Any tips about this ?

Thank you

Re: Error using limit and offset

Posted: Wed 16 Oct 2013 15:58
by luizcapu
In time... the exception raised is 'List index out of bounds (-1)'

Re: Error using limit and offset

Posted: Wed 16 Oct 2013 16:06
by luizcapu
Some more informations about my tests:

Case 1) setting offset=1 --> works fine !
select * from table order by id limit 50 offset 1;

Case 2) removing order by --> works fine !
select * from table limit 50 offset 0;

Case 2) with order by and offset=0 --> raises 'List index out of bounds (-1)'
select * from table order by id limit 50 offset 0;

Please, someone can help me with this ?

Re: Error using limit and offset

Posted: Fri 18 Oct 2013 08:30
by AlexP
Hello,

This problem is due the behaviour of TClientDataSet, not our driver. To solve the problem, you should set the poRetainServerOrder option of TDataSetProvider:

Code: Select all

DataSetProvider1.Options := [poRetainServerOrder];