Re: Update field to a column from another table - Mailing list pgsql-general

From Adrian Klaver
Subject Re: Update field to a column from another table
Date
Msg-id 57193E9B.5060808@aklaver.com
Whole thread Raw
In response to Re: Update field to a column from another table  ("drum.lucas@gmail.com" <drum.lucas@gmail.com>)
Responses Re: Update field to a column from another table
List pgsql-general
On 04/21/2016 11:52 AM, drum.lucas@gmail.com wrote:
> So when I run:
>
>     UPDATE ja_jobs t2
>     SET time_job = t1.time_job
>     FROM junk.ja_test t1
>     WHERE t2.id <http://t2.id> = t1.id <http://t1.id>
>     AND t2.time_job IS DISTINCT FROM t1.time_job;
>
>
> I get:
>
>     UPDATE 2202
>
> So I check the data by doing:
>
>     select * FROM public.ja_jobs WHERE id = 14574527
>
>
> And the "time_job" field is null....

First idea:

Are you doing this in two different sessions at the same time, so
something like this?:

     Session 1
     BEGIN;
     UPDATE ja_jobs t2
     SET time_job = t1.time_job
     FROM junk.ja_test t1
     WHERE t2.id = t1.id
     AND t2.time_job IS DISTINCT FROM t1.time_job;

     Session 2
     select * FROM public.ja_jobs WHERE id = 14574527


Where Session 2 is not seeing the UPDATE in Session 1 because the
transaction has not been COMMITed.

Second idea:

Does id = 14574527 meet the criteria AND t2.time_job IS DISTINCT FROM
t1.time_job?

>
>


--
Adrian Klaver
adrian.klaver@aklaver.com


pgsql-general by date:

Previous
From: John McKown
Date:
Subject: Re: Proper relational database?
Next
From: Gavin Flower
Date:
Subject: Re: disable ipv6?