From: | tarunt(at)chisquare(dot)in |
---|---|
To: | pgsql-bugs(at)postgresql(dot)org |
Subject: | BUG #13808: Upsert not working |
Date: | 2015-12-09 09:01:53 |
Message-ID: | 20151209090153.872.86659@wrigleys.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
The following bug has been logged on the website:
Bug reference: 13808
Logged by: TARUN
Email address: tarunt(at)chisquare(dot)in
PostgreSQL version: 9.5beta1
Operating system: Windows 7 Professional SP1
Description:
drop table daily_deposits;
create table daily_deposits
( id int,
fdd timestamp,
ldd timestamp,
fda double precision,
lda double precision
);
insert into daily_deposits (id, fdd, ldd, fda, lda) values (1,'2015-12-01
08:10:50','2015-12-01 10:10:50', 10, 9);
insert into daily_deposits (id, fdd, ldd, fda, lda) values (1,'2015-12-02
10:10:50','2015-12-02 12:10:50', 10, 9);
insert into daily_deposits (id, fdd, ldd, fda, lda) values (1,'2015-12-04
04:10:50','2015-12-04 08:10:50', 15, 20);
insert into daily_deposits (id, fdd, ldd, fda, lda) values (2,'2015-12-01
08:10:50','2015-12-01 10:10:50', 5, 10);
insert into daily_deposits (id, fdd, ldd, fda, lda) values (2,'2015-12-02
10:10:50','2015-12-02 12:10:50', 6, 12);
insert into daily_deposits (id, fdd, ldd, fda, lda) values (2,'2015-12-03
04:10:50','2015-12-04 08:10:50', 9, 11);
commit;
select * from daily_deposits;
drop table user_first_last;
create table user_first_last
( UserId int,
FirstLoginDate timestamp,
LastLoginDate timestamp,
FirstLoginAmt double precision,
LastLoginAmt double precision
);
INSERT INTO user_first_last AS ufl (UserId,
FirstLoginDate,LastLoginDate,FirstLoginAmt,LastLoginAmt)
select id, fdd, ldd,fda, lda
from daily_deposits
ON CONFLICT (UserId)
DO UPDATE
SET FirstLoginAmt = case when excluded.fdd < ufl.FirstLoginDate then
excluded.fda else ufl.FirstLoginAmt END,
LastLoginAmt = case when excluded.ldd > ufl.LastLoginDate then
excluded.lda else ufl.LastLoginAmt END,
FirstLoginDate = case when excluded.fdd < ufl.FirstLoginDate then
excluded.fdd else ufl.FirstLoginDate END,
LastLoginDate = case when excluded.ldd > ufl.LastLoginDate then
excluded.ldd else ufl.LastLoginDate END;
ERROR: column excluded.fdd does not exist
LINE 6: SET FirstLoginAmt = case when excluded.fdd < ufl.FirstLogi...
^
********** Error **********
ERROR: column excluded.fdd does not exist
SQL state: 42703
Character: 222
From | Date | Subject | |
---|---|---|---|
Next Message | alexander.ashurkov | 2015-12-09 11:26:42 | BUG #13809: Reassign owned throws error |
Previous Message | Peter Geoghegan | 2015-12-09 05:37:13 | Re: Incorrect UPDATE trigger invocation in the UPDATE clause of an UPSERT statement. |