Re: How to insert into 2 tables from a view?

Поиск
Список
Период
Сортировка
От David G Johnston
Тема Re: How to insert into 2 tables from a view?
Дата
Msg-id CAKFQuwZnpvkuo36ea5wFiiLsmaq5EEeehqKUt+88+mU520sBPQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: How to insert into 2 tables from a view?  (rob stone <floriparob@gmail.com>)
Список pgsql-general
On Tue, Dec 23, 2014 at 6:40 PM, rob stone-2 [via PostgreSQL] <[hidden email]> wrote:
Rather strange to have two tables sharing the same primary key value.
One would have thought it was a one-to-many relationship between table1
and table2.


​while not particularly common 1-to-1 relationships can be quite useful.  Even if not required for the data model and implementation using 1-to-1 makes sense if a subset of the model data has a change profile different than other parts.  One of the tables is basically static while the, hopefully smaller (column count) related table has updates performed against it.  The main table does not exhibit churn for updates and does not need the related vacuuming.

rob>>I can vaguely remember that in version 9.0 you have to use dollar quoted 
rob>>variables so the first insert would become[...]

Ppositional variable references are only required for earlier versions of SQL functions; all supported pl/pgsql functions can make use of named arguments.

Note you can also make use of (I think, not sure on the version requirements):

INSERT INTO [...] RETURNING idfield INTO variable
INSERT INTO [...] VALUES (variable);

David J.
 


View this message in context: Re: How to insert into 2 tables from a view?
Sent from the PostgreSQL - general mailing list archive at Nabble.com.

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

Предыдущее
От: rob stone
Дата:
Сообщение: Re: How to insert into 2 tables from a view?
Следующее
От: Berend Tober
Дата:
Сообщение: Re: How to insert into 2 tables from a view?