You are here: Re: ORDER BY in VIEW not working « MsSQL Server « IT news, forums, messages
Re: ORDER BY in VIEW not working

Posted by Serge Rielau on 03/07/06 17:22

RickW wrote:
> On saving CPU cycles: I would absolutely agree that a view based on
> other views should be parsed and processed so that the ordering in all
> underlying views is ignored. Unquestionably beneficial. I just didn't
> agree that the ability to retrieve an ordered set from a real-world tool
> was an unforgiveable sin against the theoretical definition of the view.
> Some do not share this libertine view.
Well, don't mistake my impassionate response for sympathy ;-)

You are correct that your DBMS is a tool, but when the tool starts
violating the very principles upon which it is built that may result in
a tactical raise in customer satisfaction, but causes longterm grief by
pasting the architecture into a corner it can't get out of.
FWIW DB2 behaves exactly the same way for the exact same reasons.
"United we stand" ;-)

Now, lets take a look at the business requirement here you have against
"the tool":
From what I understand you have these views and you'd want that when an
application selects from it it should be able to get results back in an
order which has been defined by the creator of the view. Correct?
If so the question that should be asked (from a language point of view) is:
Does the concept of a "default" or "natural" order violate the
foundation of relational algebra? I think no, as long as this default
order is _explicitly_ requested just like you can explicitly SET c1 =
DEFAULT.

Example:
CREATE TABLE T(pk NOT NULL PRIMARY KEY, c1);
SELECT * FROM T ORDER BY _ORDER_OF_T_;
This could e.g. mean: Please pick up the order defined by the primary
key index.
For "SELECT * FROM V ORDER BY ORDER OF V" this could mean to pick up teh
ORDER BY clause in the view. If you omit this the ORDER BY you get what
you get (no order).

We (IBM) have been mulling this over as an SQL standard submission.
Would be interesting to read the thoughts of Microsoft folks.

As language folks we have to be perceptive to the practical usages of
the language.

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация