nextval on insert by arbitrary sequence

Поиск
Список
Период
Сортировка
От Dado Feigenblatt
Тема nextval on insert by arbitrary sequence
Дата
Msg-id 3B5794B0.8060201@wildbrain.com
обсуждение исходный текст
Ответы Re: nextval on insert by arbitrary sequence  ("Josh Berkus" <josh@agliodbs.com>)
Re: nextval on insert by arbitrary sequence  (Henry House <hajhouse@houseag.com>)
Список pgsql-sql
I'm not sure if I worded the subject right, but my problem is this:

I have a few entries in one table. Each row is the parent of many 
entries in a second table.
In the second table I have a lot of entries referencing the entries on 
the first table.
So far so good. Basic foreign key thing.
The entries on the second table need to be numbered, but instead of a 
single sequence for all rows,
I need a sequence per group of rows, according to their parent record.

I have some ideas but they are not coming together.
I thought of creating individual sequences for each new parent row, and 
maybe store its name in the parent row itself, so it can be accessed by 
it's children row.
But then, how do I get a field on the second table to DEFAULT to 
nextval() on it's parent's sequence?

INSERT using SELECT?
TRIGGER?
RULE?
FUNCTION?
Is it best to handle this things entirely on the client ?
What is the approach for this problem?

Thanks.


PS: Hmmm... It doesn't look like I got my terminology right. Sorry for 
that.

-- 
Dado Feigenblatt                                 Wild Brain, Inc.   
Technical Director                               (415) 553-8000 x???
dado@wildbrain.com                               San Francisco, CA.





В списке pgsql-sql по дате отправления:

Предыдущее
От: "Josh Berkus"
Дата:
Сообщение: Re: Query optimizing - paradox behave
Следующее
От: "Josh Berkus"
Дата:
Сообщение: Re: nextval on insert by arbitrary sequence