Error for sort with '

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
sinys
Posts: 186
Joined: Tue 21 Feb 2012 03:44

Error for sort with '

Post by sinys » Thu 16 Aug 2012 06:35

OraQuery1.SQL.text := 'select ''1'' from dual'; // Field as string
OraQuery1.Open;
OraQuery1.IndexFieldNames := '''1'' DESC;'; // raise error Field 1 not found

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

Re: Error for sort with '

Post by AlexP » Thu 16 Aug 2012 08:01

hello,

In the provided query '1' is not the name but the field value, therefore when attempting to set IndexFieldNames, you get an error.
To use IndexFieldNames with such queries, you should use alias, i.e.:

Code: Select all

OraQuery1.SQL.text := 'select ''1'' as MyField from dual'; 
OraQuery1.Open;
OraQuery1.IndexFieldNames := 'MyField DESC;'; 
P.S. In Oracle fields can start with a letter only

sinys
Posts: 186
Joined: Tue 21 Feb 2012 03:44

Re: Error for sort with '

Post by sinys » Thu 16 Aug 2012 08:13

Can I get around it somehow indicating the serial number for sorting for example? (like sql "order by 1", but for local sorting)

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

Re: Error for sort with '

Post by AlexP » Thu 16 Aug 2012 09:15

hello,

At the moment, you cannot use field numbers in local sorting, we will review the possibility to add this feature in one of the next versions

Post Reply