Firebird SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsDatabasesFirebird SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 28th, 2011, 04:55 PM
wakerunner wakerunner is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2008
Posts: 68 wakerunner User rank is Private First Class (20 - 50 Reputation Level)wakerunner User rank is Private First Class (20 - 50 Reputation Level) 
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.

Reply With Quote
  #2  
Old May 3rd, 2011, 12:25 AM
clivew clivew is offline
Contributing User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jan 2006
Location: Carlsbad, CA
Posts: 2,045 clivew User rank is Major (30000 - 40000 Reputation Level)clivew User rank is Major (30000 - 40000 Reputation Level)clivew User rank is Major (30000 - 40000 Reputation Level)clivew User rank is Major (30000 - 40000 Reputation Level)clivew User rank is Major (30000 - 40000 Reputation Level)clivew User rank is Major (30000 - 40000 Reputation Level)clivew User rank is Major (30000 - 40000 Reputation Level)clivew User rank is Major (30000 - 40000 Reputation Level)clivew User rank is Major (30000 - 40000 Reputation Level)clivew User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Week 6 Days 2 h 37 m
Reputation Power: 382
And what is your problem?

Reply With Quote
  #3  
Old May 3rd, 2011, 08:31 AM
wakerunner wakerunner is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2008
Posts: 68 wakerunner User rank is Private First Class (20 - 50 Reputation Level)wakerunner User rank is Private First Class (20 - 50 Reputation Level) 
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 '.

Reply With Quote
  #4  
Old May 3rd, 2011, 10:38 AM
clivew clivew is offline
Contributing User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jan 2006
Location: Carlsbad, CA
Posts: 2,045 clivew User rank is Major (30000 - 40000 Reputation Level)clivew User rank is Major (30000 - 40000 Reputation Level)clivew User rank is Major (30000 - 40000 Reputation Level)clivew User rank is Major (30000 - 40000 Reputation Level)clivew User rank is Major (30000 - 40000 Reputation Level)clivew User rank is Major (30000 - 40000 Reputation Level)clivew User rank is Major (30000 - 40000 Reputation Level)clivew User rank is Major (30000 - 40000 Reputation Level)clivew User rank is Major (30000 - 40000 Reputation Level)clivew User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Week 6 Days 2 h 37 m
Reputation Power: 382
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.

Reply With Quote
  #5  
Old May 3rd, 2011, 10:55 AM
wakerunner wakerunner is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2008
Posts: 68 wakerunner User rank is Private First Class (20 - 50 Reputation Level)wakerunner User rank is Private First Class (20 - 50 Reputation Level) 
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.

Reply With Quote
  #6  
Old May 3rd, 2011, 01:02 PM
clivew clivew is offline
Contributing User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jan 2006
Location: Carlsbad, CA
Posts: 2,045 clivew User rank is Major (30000 - 40000 Reputation Level)clivew User rank is Major (30000 - 40000 Reputation Level)clivew User rank is Major (30000 - 40000 Reputation Level)clivew User rank is Major (30000 - 40000 Reputation Level)clivew User rank is Major (30000 - 40000 Reputation Level)clivew User rank is Major (30000 - 40000 Reputation Level)clivew User rank is Major (30000 - 40000 Reputation Level)clivew User rank is Major (30000 - 40000 Reputation Level)clivew User rank is Major (30000 - 40000 Reputation Level)clivew User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Week 6 Days 2 h 37 m
Reputation Power: 382
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

Reply With Quote
  #7  
Old May 4th, 2011, 01:38 AM
mIRCata mIRCata is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2006
Location: Plovdiv. Bulgaria
Posts: 200 mIRCata User rank is Corporal (100 - 500 Reputation Level)mIRCata User rank is Corporal (100 - 500 Reputation Level)mIRCata User rank is Corporal (100 - 500 Reputation Level)mIRCata User rank is Corporal (100 - 500 Reputation Level) 
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.

Reply With Quote
  #8  
Old May 4th, 2011, 01:15 PM
clivew clivew is offline
Contributing User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jan 2006
Location: Carlsbad, CA
Posts: 2,045 clivew User rank is Major (30000 - 40000 Reputation Level)clivew User rank is Major (30000 - 40000 Reputation Level)clivew User rank is Major (30000 - 40000 Reputation Level)clivew User rank is Major (30000 - 40000 Reputation Level)clivew User rank is Major (30000 - 40000 Reputation Level)clivew User rank is Major (30000 - 40000 Reputation Level)clivew User rank is Major (30000 - 40000 Reputation Level)clivew User rank is Major (30000 - 40000 Reputation Level)clivew User rank is Major (30000 - 40000 Reputation Level)clivew User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Week 6 Days 2 h 37 m
Reputation Power: 382
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesFirebird SQL Development > Reverse order of records in recordset

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap