Subject | Re: [firebird-support] change record order |
---|---|
Author | Markus Ostenried |
Post date | 2004-02-12T23:46:18Z |
At 15:49 Thursday, 12.02.2004 +0000, you wrote:
You are looking for a way to set a record's "vertical" position in its
table (like you can change the "horizontal" position of a column in the
table) ?
In firebird (and every true RDBMS) a record doesn't have any specific
position in a table. And you don't have access to its physical position
because it's meaningless: after you delete some records then firebird will
fill the gaps with new inserted records. Also, after a backup/restore the
physical order can change AFAIK.
So you have to define a new column that you can then use to order your
records: you could create a new integer column and fill it with unique
values supplied by a generator. To move a record you have to swap two
values of the ordering column. Or you could use Double as type for the
ordering column because then it's easier to insert new records between
existing ones.
HTH,
Markus
>is it any simple way (as RDB$FIELD_POSITION) to change record positionNot sure if I understand what you want to do - please correct me if I'm wrong:
>in column? or I must add additional attribute to specify position
>records position in the table (problems when changing order as
>neighbours take action too)
>I have record list in listbox and need to change their order in the
>table - move up or down (1 2 3 4 => 1 2 4 3 => 1 4 2 3)
>Or there is more ways?
You are looking for a way to set a record's "vertical" position in its
table (like you can change the "horizontal" position of a column in the
table) ?
In firebird (and every true RDBMS) a record doesn't have any specific
position in a table. And you don't have access to its physical position
because it's meaningless: after you delete some records then firebird will
fill the gaps with new inserted records. Also, after a backup/restore the
physical order can change AFAIK.
So you have to define a new column that you can then use to order your
records: you could create a new integer column and fill it with unique
values supplied by a generator. To move a record you have to swap two
values of the ordering column. Or you could use Double as type for the
ordering column because then it's easier to insert new records between
existing ones.
HTH,
Markus