Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1ewv1t-0002HA-Mq for pgsql-general@arkaria.postgresql.org; Fri, 16 Mar 2018 19:28:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ewv1q-0007sd-P0 for pgsql-general@arkaria.postgresql.org; Fri, 16 Mar 2018 19:28:38 +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.89) (envelope-from ) id 1ewv1q-0007sH-5q for pgsql-general@lists.postgresql.org; Fri, 16 Mar 2018 19:28:38 +0000 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1ewv1Z-0001Y9-Cs for pgsql-general@postgresql.org; Fri, 16 Mar 2018 19:28:37 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 5418821215; Fri, 16 Mar 2018 15:28:19 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute6.internal (MEProxy); Fri, 16 Mar 2018 15:28:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; bh=ViH7MClwx6/xyQuC2+psVZbC3d2hr +BbZ4NRC/W6MKQ=; b=TtPhkSSCLX0txkqJ4kfv2FuiMENjNj/IHOy+AXdqM3vOj dEmy7/YoBAtKuYa+qnYIz91DYmximgMf+soothUZMadpRoncbenac05ZfB11thMC Yf4hlBX8BRcvIdGjCDmdL0LQkjlzT7a+yCLnJf8haxBNu+2z4+BJaW2yG2+nlt3P iIUbJcvVuc+MmoQ/CPzu8m2ma8JF+Rp9mVd82BZppFR9erx4RZ0T7e2tIAGPPNWd RphfbxmyIFG6cnEEz/wBxkwV4ySnZ82UYdA3Swx6DidgPlLQwdMyPIMowBYOVOVs ENB41zDx0sQKNYQpnfsgn5+fJIub5vZP7ugKkpoMA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=ViH7MC lwx6/xyQuC2+psVZbC3d2hr+BbZ4NRC/W6MKQ=; b=mBZMJ0KTPG1VQhcttatTwT R1V4blklrtkp53wwrCux+7siXC6XPj8aj01yXqOG4YHOuFDVxud+nFIhOWXinDvF viuQ1glL4tRYg7NIgIJnSqoiqd3AEUsp+sTyIypLa191DkfxpkGSsGW78xaoaptj joMxeUbFzEU+4o6ea782JonxRVyGtfo6jsnBrUtwLOAP5A8chqHywwnlbTxB6Lk3 NkzabqKcHjfUel8xM4qdh/TG9W2yYGt/DJRdM2RGxeH0TypUzlhX+e2/vps81g7H WYpHs04nWlmJgXmffYiNJrSQfqHPRkSwtD/7AaVoGoM57IERXjqlp/zZY7BXc9Xg == X-ME-Sender: Received: from [192.168.1.2] (71-35-123-124.tukw.qwest.net [71.35.123.124]) by mail.messagingengine.com (Postfix) with ESMTPA id ADB107E0A5; Fri, 16 Mar 2018 15:28:18 -0400 (EDT) Subject: Re: ora2pg and invalid command \N To: Charlin Barak , Pavel Stehule Cc: "pgsql-general@postgresql.org >> PG-General Mailing List" References: From: Adrian Klaver Message-ID: <1a55abfc-1656-1223-ecd7-ab69c1e8db7f@aklaver.com> Date: Fri, 16 Mar 2018 12:28:17 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 03/16/2018 11:36 AM, Charlin Barak wrote: > Thanks for your response. > > the NULL values from Oracle were indeed replaced by \N in the data > output. How do I go about loading this file? I hope I do not have to > temporary replace \N with a string in the flat file and then later > update in Postgres. That should not be necessary: https://www.postgresql.org/docs/10/static/sql-copy.html "NULL Specifies the string that represents a null value. The default is \N (backslash-N) in text format, and an unquoted empty string in CSV format. You might prefer an empty string even in text format for cases where you don't want to distinguish nulls from empty strings. This option is not allowed when using binary format." To solve this is going to require more information. From my previous post: What was the complete command you used to generate the data file? Can we see the complete error? Also a section of the data file that contains the data that caused the error? > > Thanks. > > 102     48299   50  C       3      \N > 103     48299   \N  G       3      45 > ... > ... > > On Fri, Mar 16, 2018 at 2:06 PM, Pavel Stehule > wrote: > > > > 2018-03-16 18:12 GMT+01:00 Charlin Barak >: > > Hi, > I'm using ora2pg to migrate our Oracle database to Postgres. I > was able to generate the data file using TYPE=COPY but when I > attempted to load the file via psql, I got lots of "invalid > command \N" errors. The resolution on the internet was not clear > and was  not ora2pg related. How do I resolve this issue? Can > someone provide some guidance? > > > \N is symbol for NULL. but \cmd are psql commands too. This behave > means so psql lost synchronization and try to eval data like > commands. psql import is tolerant - that means so source of this > issue is lost usually. Try to import data with option ON_ERROR_STOP > > https://stackoverflow.com/questions/4480381/postgres-sql-fail-on-script-error > > > Regards > > Pavel > > > Thanks. > > > > > > -- Adrian Klaver adrian.klaver@aklaver.com