Re: VS: Delete after trigger fixing the key of row numbers

From: brian <brian(at)zijn-digital(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: VS: Delete after trigger fixing the key of row numbers
Date: 2008-03-28 18:02:15
Message-ID: 47ED32A7.3040106@zijn-digital.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Teemu Juntunen, e-ngine wrote:
> Hi Tomasz,
>
> with receipt rows I can't see any other option with key as running number.
> First I tried to use serial, but it didn't start from zero again when the
> foreign key (receipt number) changes. It just continues the serial despite
> of the foreign key.
>
> Then I decided to do my own serial which keeps it in order even when some
> rows are deleted from the middle. Of course I could just leave the row
> numbers as is, but there are some advantages at the program, if the serial
> is linear. What is the danger you see in this row number update trigger?
>

If you'd like to have a linear count of your result set it shouldn't be
difficult to implement that in your client-side application code (for
loop, for instance). You don't need to use the serial for display
purposes but it's very helpful for maintaining intact relations.

Besides, if this table has any associations with others, doing this
would seem to make your archived data next to useless if you ever need it.

b

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Merlin Moncure 2008-03-28 18:19:55 Re: trouble selecting from array
Previous Message Pavel Stehule 2008-03-28 17:51:31 Re: PL/pgSQL Documentation, biblio, etc