Re: Update two tables returning id from insert CTE Query - Mailing list pgsql-general

From David G. Johnston
Subject Re: Update two tables returning id from insert CTE Query
Date
Msg-id CAKFQuwYgmmJSqaudTMdx+VFDLOfjwW7i1o4RF9n6ptBOmkgy9w@mail.gmail.com
Whole thread Raw
In response to Re: Update two tables returning id from insert CTE Query  (Igor Neyman <ineyman@perceptron.com>)
List pgsql-general
On Tue, Sep 27, 2016 at 1:10 PM, Igor Neyman <ineyman@perceptron.com> wrote:

 

Patrick,

 

You need to explain your problems in more “coherent” way, David suggested one.

If you aren’t willing,  people will stop responding to your request, they are not obligated to read your mind.

 


​I'll put it this way - the only conclusion I can draw in reading the provided code is that the data model is screwed up and may not be capable of accommodating this goal.  Albeit this is based upon a incompletely specified model...

​If you want table1 and table2 to have a 1-to-1 relationship then the assignment of the unique key should not occur via next_val() calls in the default expression​ of either table.  When you query "not_monthly" you need to figure out what the new ID should be and explicitly add it to both INSERT statements.

David J.

pgsql-general by date:

Previous
From: Igor Neyman
Date:
Subject: Re: Update two tables returning id from insert CTE Query
Next
From: Kevin Grittner
Date:
Subject: Re: Update two tables returning id from insert CTE Query