Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1a6k7f-0006eh-Uh for pgsql-bugs@arkaria.postgresql.org; Wed, 09 Dec 2015 19:09:56 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1a6k7f-0006La-Gf for pgsql-bugs@arkaria.postgresql.org; Wed, 09 Dec 2015 19:09:55 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1a6adU-0007JE-Uv for pgsql-bugs@postgresql.org; Wed, 09 Dec 2015 09:02:08 +0000 Received: from wrigleys.postgresql.org ([204.145.124.246]) by magus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1a6adR-0005ul-1o for pgsql-bugs@postgresql.org; Wed, 09 Dec 2015 09:02:07 +0000 MIME-Version: 1.0 Subject: BUG #13808: Upsert not working To: pgsql-bugs@postgresql.org From: tarunt@chisquare.in Date: Wed, 09 Dec 2015 09:01:53 +0000 Message-ID: <20151209090153.872.86659@wrigleys.postgresql.org> X-Pg-Spam-Score: -1.2 (-) Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org The following bug has been logged on the website: Bug reference: 13808 Logged by: TARUN Email address: tarunt@chisquare.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 -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs