From: | Russell Smith <mr-russ(at)pws(dot)com(dot)au> |
---|---|
To: | Bruno Wolff III <bruno(at)wolff(dot)to> |
Cc: | Andrus Moor <eetasoft(at)online(dot)ee>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: Using sequence name depending on other column |
Date: | 2005-03-13 06:11:34 |
Message-ID: | 200503131711.34700.mr-russ@pws.com.au |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Sun, 13 Mar 2005 02:59 pm, Bruno Wolff III wrote:
> On Sat, Mar 12, 2005 at 23:05:41 +0200,
> Andrus Moor <eetasoft(at)online(dot)ee> wrote:
> > I have table containing different types of documents (type A, B and C).
> >
> > Each document type must have separate sequential ID starting at 1
> >
> > ID of first inserted record of type A must be set to 1
> > ID of first inserted record of type B must be also set to 1
> > ID of second record of type A must be set to 2
> > etc.
>
If you are happy with the fact that a sequence may leave a whole in
the numbers. You are probably best to no set a default value for an
integer, or big integer. Then run a before trigger for each row. That
trigger will assign a value to the column based on the value given for
the type.
Regards
Russell Smith
From | Date | Subject | |
---|---|---|---|
Next Message | Ron Mayer | 2005-03-13 06:11:44 | Re: [PATCHES] A way to let Vacuum warn if FSM settings are low. [final?] |
Previous Message | Bruce Momjian | 2005-03-13 05:42:11 | Re: [PATCHES] A way to let Vacuum warn if FSM settings are low. [final?] |