Re: Update two tables returning id from insert CTE Query

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Igor Neyman <ineyman(at)perceptron(dot)com>
Cc: Patrick B <patrickbakerbr(at)gmail(dot)com>, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Update two tables returning id from insert CTE Query
Date: 2016-09-27 20:19:56
Message-ID: CAKFQuwYgmmJSqaudTMdx+VFDLOfjwW7i1o4RF9n6ptBOmkgy9w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Sep 27, 2016 at 1:10 PM, Igor Neyman <ineyman(at)perceptron(dot)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.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Kevin Grittner 2016-09-27 20:23:11 Re: Update two tables returning id from insert CTE Query
Previous Message dudedoe01 2016-09-27 20:12:44 Re: isnull() function in pgAdmin3