Subject Re: INSERT INTO...SELECT...ORDER BY
Author uwekeim
--- In firebird-support@yahoogroups.com, "Svein Erling"
<svein.erling.tysvaer@k...> wrote:
> --- In firebird-support@yahoogroups.com, "uwekeim" wrote:
> > Hello,
> >
> > I want to insert some ordered records into an empty table, but
> > Firebird seems not to support "ORDER BY" in an insert-clause (why
> > not???).
> >
> > Is there any workaround?
>
> In theory, there is no such thing as an order amongst the stored
> records of Firebird. You may ask for ordered records when you take
> them out of the database (SELECT... ORDER BY...), but within the
> database there is approximately as much order as amongst the
clothes
> within a washing machine. You may find there to be a certain order
> ('hey, I inserted these records in this order, and it is almost
what I
> get out without any order by clause'), but I would not trust any
such
> accidental ordering unless someone deep into the source code told
me
> it was safe. You'd better use indexes and order your data when
taking
> them out of the database.
>
> Set

hmmm...let me try to explain what I'm going to to (sorry, my english
is not very good):

I have an application, that builds a tree-structure based on a db-
table, connected via ODBC. Unfortunately I can't change this
application.

This app builds the tree ordered by a keynumber (ID). Because I want
this tree to be ordered by the manufacturer-names, the ID must be
assigned to the names ordered same way - I hope You see what I mean.

So I built a generator to generate the ID and a "on-insert"-trigger
into the manufacturer-table.
Before starting the app, I clear the table, set the generator to 0
and insert the ordered records from another table, which contains the
articles of several
manufactureres . As result i get the ID ordered
by names.

Do You know a better way to solve this task?