Search Postgresql Archives

Re: Error with Insert from View with ON Conflict

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx> 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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux