I'd like to be able to (effectively) sort a database view - I know that conceptually order in a db view is invalid, but I have the following scenario to deal with:
- a third-party legacy application, that reads data from database tables using a select(*) from tablename statement
- the legacy application is very sensitive to the order of the records
- an application I've written to allow users to manage the data in the tables more easily, but inserts and deletes from the table naturally upset the order of the records.
Changing the statement in the legacy application to select (*) from tablename order by field would fix my problem, but isn't an option.
So - I've set up a staging table into which the data can be exported in the right order, but this is a resource-hungry option, means that the data isn't 'live' in the legacy application and is additional work for users.
I'd like to be able to get at an ordered version of the table with these contraints. Any ideas how?
Update - I'm working with Sybase 12.5, but I'd like to avoid a tightly coupled solution with a specific RDBMS - it might change.
I cannot add an 'order by' clause to a view, because of SQL standards as referred to in this Wikipedia entry