The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Databases
> Firebird SQL Development
|
Reverse order of records in recordset
Discuss Reverse order of records in recordset in the Firebird SQL Development forum on Dev Shed. Reverse order of records in recordset Firebird SQL Development forum discussing administration, Firebird SQL syntax, or other Firebird SQL-related topics. Firebird is the evolution of Borland's Interbase product.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

April 28th, 2011, 04:55 PM
|
|
Contributing User
|
|
Join Date: Nov 2008
Posts: 68

Time spent in forums: 12 h 49 m
Reputation Power: 5
|
|
|
Order by and sort differences
I have run into an issue with sorting/ordering field values that contain parathesis. If use use a string like below:
select * from table where name >='O' order by name asc
I will get records like this:
o'hara
o'neil
oken
onet
If I use the command below on a recordset with the same records
recordset.sort ="name asc"
They are ordered like below, as if the apostraphy isn't there
o'hara
oken
onet
o'neil
Any idea what can cause this?
Last edited by wakerunner : April 28th, 2011 at 10:14 PM.
|

May 3rd, 2011, 12:25 AM
|
|
Contributing User
|
|
Join Date: Jan 2006
Location: Carlsbad, CA
|
|
|
And what is your problem?
|

May 3rd, 2011, 08:31 AM
|
|
Contributing User
|
|
Join Date: Nov 2008
Posts: 68

Time spent in forums: 12 h 49 m
Reputation Power: 5
|
|
Quote: | Originally Posted by clivew And what is your problem? |
The problem is why does "order by name asc" sort differently than "sort = name asc"... shouldn't they sort the same?
"Order by name asc" orders like below
o'hara
o'neil
oken
onet
recordset.sort ="name asc" orders like below as if the ' are not there.
o'hara
oken
o'neil
onet
Is there a setting I am missing somewhere or maybe something in the connection string that could cause this? I also noticed that once you use the ".sort" command subsequent "order by"'s will also order the same wrong way as if there are no '.
|

May 3rd, 2011, 10:38 AM
|
|
Contributing User
|
|
Join Date: Jan 2006
Location: Carlsbad, CA
|
|
|
So this is curiosity , not a problem. OK that is fair.
Perhaps I am not as familiar with Firebird as I thought; but I am not familiar with your recordset.sort and similar code.
It is not SQL and I have not come across it in Firebird procedural code.
|

May 3rd, 2011, 10:55 AM
|
|
Contributing User
|
|
Join Date: Nov 2008
Posts: 68

Time spent in forums: 12 h 49 m
Reputation Power: 5
|
|
Quote: | Originally Posted by clivew So this is curiosity , not a problem. OK that is fair.
Perhaps I am not as familiar with Firebird as I thought; but I am not familiar with your recordset.sort and similar code.
It is not SQL and I have not come across it in Firebird procedural code. |
No it is a problem not a curiosity. The problem is if you do "select name from table order by name" then do "recordset.sort = name desc", then "recordset.sort = name asc" it should be in the same order as it was to begin with... it is not.
recordset.sort is a ADO recordset function. I am using ADO 2.8 with IBphoenix Ole-DB provider. Ibphoenix told me it is probably an issue with Firebird itself, I need to update to 2.5 anyway so I'm going to do that soon and see if it changes anything, if it doesn't I'll just have to make a workaround, or just not use recordset.sort.
|

May 3rd, 2011, 01:02 PM
|
|
Contributing User
|
|
Join Date: Jan 2006
Location: Carlsbad, CA
|
|
|
I am reluctant to argue with IBPhoenix; but if the SQL provides the correct result (which it does given ASCII rules) then the problem is with ADO, which has nothing to do with Firebird per se.
Unless there is some recordset property that addresses this complication, it looks like you will just have to decide which option you want.
If the SQL(ASCII) sort is required then you will have to issue a fresh SQL request each time.
If the ADO sort option is required, then don't bother to sort in the SQL SELECT and do it in the recordset as soon as the query completes.
Clive
|

May 4th, 2011, 01:38 AM
|
|
Contributing User
|
|
Join Date: Sep 2006
Location: Plovdiv. Bulgaria
Posts: 200
  
Time spent in forums: 2 Days 6 h 50 m 4 sec
Reputation Power: 11
|
|
|
It's look like ADO removes the ' from the names and sorts them after that.
|

May 4th, 2011, 01:15 PM
|
|
Contributing User
|
|
Join Date: Jan 2006
Location: Carlsbad, CA
|
|
Quote: | Originally Posted by mIRCata It's look like ADO removes the ' from the names and sorts them after that. |
I think we all figured that one out. 
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|