Re: How to insert into 2 tables from a view? - Mailing list pgsql-general

From David G Johnston
Subject Re: How to insert into 2 tables from a view?
Date
Msg-id CAKFQuwZnpvkuo36ea5wFiiLsmaq5EEeehqKUt+88+mU520sBPQ@mail.gmail.com
Whole thread Raw
In response to Re: How to insert into 2 tables from a view?  (rob stone <floriparob@gmail.com>)
List 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 by date:

Previous
From: rob stone
Date:
Subject: Re: How to insert into 2 tables from a view?
Next
From: Berend Tober
Date:
Subject: Re: How to insert into 2 tables from a view?