From: | Steve Baldwin <steve(dot)baldwin(at)gmail(dot)com> |
---|---|
To: | Alex Magnum <magnum11200(at)gmail(dot)com> |
Cc: | Postgres General <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Error with Insert from View with ON Conflict |
Date: | 2021-11-03 21:18:20 |
Message-ID: | CAKE1AiacP9Eu-cxWbkJ+LBCzwGUH2mujH7t1eWncD0ePWx2C=w@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
I'm pretty sure the 'alias' for the '.. on conflict do update ..' needs to
be 'excluded' (i.e. checks = excluded.checks, ...). Check the docs.
Steve
On Thu, Nov 4, 2021 at 8:05 AM Alex Magnum <magnum11200(at)gmail(dot)com> wrote:
> Hi,
> I am trying to do an upsert using a view but for some reason get errors.
> All works fine without the ON CONFLICT
>
> INSERT INTO http_stats
> SELECT * FROM view_http_stats AS V WHERE month =date_trunc('month',now())
> ON CONFLICT (url,ip,month) DO UPDATE
> SET last_update = now(),
> checks = V.checks,
> uptime = V.uptime,
> errors = V.errors;
>
> ERROR: 42P01: missing FROM-clause entry for table "v"
> LINE 5: checks = V.checks,
> ^
> LOCATION: errorMissingRTE, parse_relation.c:3460
>
> Any help would be appreciated. Thanks in advance.
>
> A
>
From | Date | Subject | |
---|---|---|---|
Next Message | Adrian Klaver | 2021-11-03 22:14:49 | Re: to_date() and to_timestamp() with negative years |
Previous Message | Alex Magnum | 2021-11-03 21:05:19 | Error with Insert from View with ON Conflict |