Re: insert related data into two tables

Поиск
Список
Период
Сортировка
От Patrick JACQUOT
Тема Re: insert related data into two tables
Дата
Msg-id 447184F0.1050603@anpe.fr
обсуждение исходный текст
Ответ на insert related data into two tables  (filippo2991@virgilio.it)
Список pgsql-sql
filippo2991@virgilio.it wrote:

>Hello,
>
>I have two tables like these:
>
>TABLE_1:  people registry
>fields: ID_T1, SURNAME, NAME
>ID_T1 is primary key
>
>TABLE_2: work groups
>fields: ID_T2, TASK
>ID_T2 is foreign key related to ID_T1
>
>the first table is the list of employees, the second the task.
>
>Sometime I need to insert a new employee and at the same time the task
>for him:
>I want to INSERT TO table 1 JOHN DOE (the ID is assigned automatically
>since it's a primary key) and INSERT TO table 2 the ID and the task
>name for JOHN DOE. Is it possible to create a single query? What is the
>best way to do this?
>
>Thanks,
>
>Filippo
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 3: Have you checked our extensive FAQ?
>
>               http://www.postgresql.org/docs/faq
>
>  
>
maybe you could create a view for the join of the two tebles,
then make that view writable by creating the
appropriate triggers.
Then a single insert into the view would in fact create everything.


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: timestamp query doesn't use an index ...
Следующее
От: Mark Fenbers
Дата:
Сообщение: Does PG have a database