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 1gi8U0-0004bV-KI for pgsql-general@arkaria.postgresql.org; Sat, 12 Jan 2019 01:53:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gi8Ty-0006lO-8l for pgsql-general@arkaria.postgresql.org; Sat, 12 Jan 2019 01:53:06 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gi8Tx-0006i8-1X for pgsql-general@lists.postgresql.org; Sat, 12 Jan 2019 01:53:06 +0000 Received: from mail-oln040092014043.outbound.protection.outlook.com ([40.92.14.43] helo=NAM05-DM3-obe.outbound.protection.outlook.com) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gi8To-0006ry-M7 for pgsql-general@lists.postgresql.org; Sat, 12 Jan 2019 01:53:03 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=35D1lFMXbuMKQqzpCXwDVOGVeRQ/3TfAaW6rJAj6Npg=; b=F8IcUCXIhHWAxcLNdbmO3hlvRnE22PGuZB2rYRegiZIyNuaTVEUTzbgB2KMgvj5Odqx7d95ZWhXoKJrvQx9sBsV1na3MH6oRCmTpfYpui4n2U3wvRqHNcUkgwCdQsQ9S1qw5bZl1WyaOCVS+DKYsZqt/MrRrku6BakluJiB8QKqdfwI762a2Ly0eFk2rk7FFDYPbYntJiRX+KVJVRp0472qs8Czw+ybRdc9Vhc2VxTd9UpTVXgwBbTfygXTCF5Gz0NZkbqKFTKhzmHW0ozn23oaSATKZ8Qi/hvx30HQeMSSO9OLRi2PfkDIeO/iyyODyIxWfHZYytyEIBHv2luTiRA== Received: from CO1NAM05FT048.eop-nam05.prod.protection.outlook.com (10.152.96.58) by CO1NAM05HT067.eop-nam05.prod.protection.outlook.com (10.152.97.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1537.10; Sat, 12 Jan 2019 01:52:54 +0000 Received: from SC1P15201MB2304.LAMP152.PROD.OUTLOOK.COM (10.152.96.53) by CO1NAM05FT048.mail.protection.outlook.com (10.152.96.163) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1537.10 via Frontend Transport; Sat, 12 Jan 2019 01:52:54 +0000 Received: from SC1P15201MB2304.LAMP152.PROD.OUTLOOK.COM ([fe80::cd74:6b5:766c:1dc2]) by SC1P15201MB2304.LAMP152.PROD.OUTLOOK.COM ([fe80::cd74:6b5:766c:1dc2%8]) with mapi id 15.20.1516.016; Sat, 12 Jan 2019 01:52:54 +0000 From: Ricardo Martin Gomez To: Rich Shepard , "pgsql-general@lists.postgresql.org" , Adrian Klaver Subject: Re: insert into: NULL in date column Thread-Topic: insert into: NULL in date column Thread-Index: AQHUqgDpP8mY5QomRUGdtt+JnDIAy6WqsGKAgAAEQoCAAAETAIAAArKAgAAHWACAABMKAIAACgkA Date: Sat, 12 Jan 2019 01:52:54 +0000 Message-ID: References: <410b055a-24a7-5e15-f4e6-462e64794530@gmail.com> , In-Reply-To: Accept-Language: es-AR, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:875A7B9ABF90CC7029B87218ABA3A1D1148104C39FC9DDE9DE49C27E770CB541;UpperCasedChecksum:EB878930C18442295B6CFC6D14E135D2525333C20F51B25E6C76D72956063DC1;SizeAsReceived:7521;Count:46 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [uA1CjYtzytWEiUn4PeXYouER618vVY6Y] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;CO1NAM05HT067;6:0jGrL1DSi1LzhXIjHogaUPN0pXtUycDzhYlN4m6KWpWpAVNdclU5mnW+K6G73RWadNzDZEkpruUrYQjAnpuqSoAHs5CXJRauzy3d1elLTdJC1XCpk4c050NapkXOKGtrv2sk5YTwmPSC2/XKQvh7VRFkktz8Jvcgyw9Vw9tkhaGwR1KMGRYpl6so+05ioB604j9mxFle49PxG8x0OWA+hY/c/88A4s+S+uP+JGnAZd2l4zW7LY/IXmCY0mKDw/dHDeMhdyQSCH5+LJuRGwYFgX0Ie1QQrptKUfslSmttZgWIMVHuZyq0FNXEbHZZzAM7PA9KMQ93qnUN1yo9IrCDodBvlNCjiYqphks0tqLTXIyq6r4gQhZ3UwFs8QhkhHB6vrDG5YYwW/6XvzReTRFe06v+bVV/bpeJv8h7XRGs2KtOWbgKEHjpN6DDnva8/XuR6ZStf/AsASbh03/gkCvyog==;5:vxp9IxMFF9600QKwOORaGHNdYiJrVJkAVaqgxX37dOaU6GcyYUZVY5w6Z/PlYt6dvtPgM0fWoeP+DM4cOQUsc7G1vQXEeq6HCFKWwyrZdA1CcBAJlsp7trhrvWu/0/kxmVd6d/nqnhmKFrcKUHVhdft6HmvCSr6ckYkrxJHIhTgqbkmuMZlLMSuHTPLwtO9mdazz7aGqjbpjti4n1MMm9Q==;7:c+hFcJRc5cIYB9HKRYJIPtnSiYZn61Wmwizwv7XUU4cdty3/YCihtPqpuokl2UNC76PcRjftQJtG8KLbxhV5o26amBzBcN3Tv3c7qeYwsENAF4h+/9zhPldZfTL5yvi6XuFkCl1xrR/zFSw+RP4HIQ== x-incomingheadercount: 46 x-eopattributedmessage: 0 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(201702061078)(5061506573)(5061507331)(1603103135)(2017031320274)(2017031323274)(2017031324274)(2017031322404)(1601125500)(1603101475)(1701031045);SRVR:CO1NAM05HT067; x-ms-traffictypediagnostic: CO1NAM05HT067: x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(4566010)(82015058);SRVR:CO1NAM05HT067;BCL:0;PCL:0;RULEID:;SRVR:CO1NAM05HT067; x-microsoft-antispam-message-info: KtHbUgFSU3eODHg3Kvz2aqfTlu/BSyZ8bM2bXVM5d6DFmEQW8nE7uD4ib/IZfWYy Content-Type: multipart/alternative; boundary="_000_SC1P15201MB230471B7A1936DDD1652766BA3860SC1P15201MB2304_" MIME-Version: 1.0 X-OriginatorOrg: hotmail.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: f12efbb0-867f-4c93-8261-502eceebfafa X-MS-Exchange-CrossTenant-Network-Message-Id: 713c35e2-8123-4fcf-a337-08d67830ab2c X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: f12efbb0-867f-4c93-8261-502eceebfafa X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Jan 2019 01:52:54.4776 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1NAM05HT067 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --_000_SC1P15201MB230471B7A1936DDD1652766BA3860SC1P15201MB2304_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi, one question. Do you put explicit "NULL" in the column value? Other option is. You have to delete the column "next_contact" in your INSERT clause. So, if the column has a default value, this value Will be inserted. Else Nu= ll value will be inserted. Regards Obtener Outlook para Android De: Adrian Klaver Enviado: viernes, 11 de enero 22:09 Asunto: Re: insert into: NULL in date column Para: Rich Shepard, pgsql-general@lists.postgresql.org On 1/11/19 4:00 PM, Rich Shepard wrote: > On Fri, 11 Jan 2019, Ken Tanzer w= rote: > >> I think the problem is actually that you're trying to represent = your NULL >> dates with '', which PG doesn't like. > > Ken, > > That's ce= rtainly how I saw the error message. > >> cat test.csv >> >> my_text,my_dat= e,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 synt= ax 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 you= rs, 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 t= reated as strings I thought their > absence > also needed the quotes. Stay = tuned to this mail list for test results. Dates are not treated as strings = they are treated as dates. There is built casting for strings that are vali= d dates though: create table date_test(dt_fld date); insert into date_test = values('01/11/19'); INSERT 0 1 --Trying MySQL 'null':) insert into date_tes= t values('00/00/0000'); ERROR: date/time field value out of range: "00/00/0= 000" LINE 1: insert into date_test values('00/00/0000'); insert into date_t= est values(''); ERROR: invalid input syntax for type date: "" LINE 1: inser= t into date_test values(''); As pointed out you are being told '' is not a = valid date. > > Thanks, > > Rich > > -- Adrian Klaver adrian.klaver@aklaver= .com --_000_SC1P15201MB230471B7A1936DDD1652766BA3860SC1P15201MB2304_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable
Hi, one question.
Do you put explicit "NULL" in the column value?
Other option is.
You have to delete the column "next_contact" in your INSERT claus= e.
So, if the column has a default value, this value Will be inserted. Else Nu= ll value will be inserted.

Regards

De: Adrian Klaver
Enviado: viernes, 11 de enero 22:09
Asunto: Re: insert into: NULL in date column
Para: Rich Shepard, pgsql-general@lists.postgresql.org


On 1/11/19 4:00 PM, Rich Shepard wrote: > On Fri, 11 Jan 2019, Ken Tanze= r wrote: > >> I think the problem is actually that you're trying t= o represent your NULL >> dates with '', which PG doesn't like. > &= gt; Ken, > >   That's certainly how I saw the error message. > >> cat test.csv >> >> my_text,my_date,my_int >&g= t; 'Some Text','1/1/18',3 >> 'More Text,,2 >> 'Enough','',1 >= ;> >> CREATE TEMP TABLE my_test (my_text TEXT, my_date DATE, my_in= t INT); >> >> \copy my_test FROM test.csv WITH CSV HEADER >&= gt; >> ERROR:  invalid input syntax for type date: "''" >> CONTEXT:  COPY my_test,= line 4, column my_date: "''" >> >> >> You'll n= ote 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 th= eir > absence > also needed the quotes. Stay tuned to this mail list = for test results. Dates are not treated as strings they are treated as date= s. There is built casting for strings that are valid dates though: create table date_test(dt_fld date); insert into d= ate_test values('01/11/19'); INSERT 0 1 --Trying MySQL 'null':) insert into= date_test values('00/00/0000'); ERROR: date/time field value out of range:= "00/00/0000" LINE 1: insert into date_test values('00/00/0000'); insert into date_test values(''); ERROR: i= nvalid input syntax for type date: "" LINE 1: insert into date_te= st values(''); As pointed out you are being told '' is not a valid date. &g= t; > Thanks, > > Rich > > -- Adrian Klaver adrian.klaver@akl= aver.com

--_000_SC1P15201MB230471B7A1936DDD1652766BA3860SC1P15201MB2304_--