[SQL] data dependent sequences?

2007-07-15 Thread Stuart McGraw
Advice requested :-) I have a table like: CREATE TABLE items ( id INT, typ INT... PRIMAY KEY (seq,typ)); I would like 'id' to be like a SERIAL except that I want independent sequences for each value of 'typ'. So if 'items' is: id typ +- 1 'a' 2 'a'

Re: [SQL] data dependent sequences?

2007-07-15 Thread Ragnar
On sun, 2007-07-15 at 09:28 -0600, Stuart McGraw wrote: > Advice requested :-) I have a table like: > > CREATE TABLE items ( > id INT, > typ INT... > PRIMAY KEY (seq,typ)); > > I would like 'id' to be like a SERIAL except that I > want independent sequences for each value of 'typ

Re: [SQL] data dependent sequences?

2007-07-15 Thread chester c young
> > CREATE TABLE items ( > id INT, > typ INT... > PRIMAY KEY (seq,typ)); > >id typ > +- > 1 'a' > 2 'a' > 3 'a' > 1 'b' > 4 'a' > 2 'b' > you will need to use pre insert trigger since you cannot use column references in defaul