Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gi6jS-00068B-T8 for pgsql-general@arkaria.postgresql.org; Sat, 12 Jan 2019 00:00:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gi6jR-0008Ad-6T for pgsql-general@arkaria.postgresql.org; Sat, 12 Jan 2019 00:00:57 +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_SHA1:256) (Exim 4.89) (envelope-from ) id 1gi6jQ-0008AU-UZ for pgsql-general@lists.postgresql.org; Sat, 12 Jan 2019 00:00:56 +0000 Received: from mail.appl-ecosys.com ([50.126.108.78]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gi6jO-00050A-Qf for pgsql-general@lists.postgresql.org; Sat, 12 Jan 2019 00:00:56 +0000 Received: from salmo.appl-ecosys.com (salmo.appl-ecosys.com [192.168.55.1]) by mail.appl-ecosys.com (Postfix) with ESMTP id EA0239934D for ; Fri, 11 Jan 2019 16:00:52 -0800 (PST) Date: Fri, 11 Jan 2019 16:00:52 -0800 (PST) From: Rich Shepard To: pgsql-general@lists.postgresql.org Subject: Re: insert into: NULL in date column In-Reply-To: Message-ID: References: <410b055a-24a7-5e15-f4e6-462e64794530@gmail.com> User-Agent: Alpine 2.20 (LNX 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset=US-ASCII List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Fri, 11 Jan 2019, Ken Tanzer wrote: > I think the problem is actually that you're trying to represent your NULL > dates with '', which PG doesn't like. Ken, That's certainly how I saw the error message. > cat test.csv > > my_text,my_date,my_int > 'Some Text','1/1/18',3 > 'More Text,,2 > 'Enough','',1 > > CREATE TEMP TABLE my_test (my_text TEXT, my_date DATE, my_int INT); > > \copy my_test FROM test.csv WITH CSV HEADER > > ERROR: invalid input syntax for type date: "''" > CONTEXT: COPY my_test, line 4, column my_date: "''" > > > You'll note that it breaks on the last line, which is like yours, not > the one before it. Huh! I'll leave off the quote marks and see if that makes a difference ... tomorrow morning. Since dates are treated as strings I thought their absence also needed the quotes. Stay tuned to this mail list for test results. Thanks, Rich