pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Charlin Barak <charlinbarak@gmail.com>
To: Pavel Stehule <pavel.stehule@gmail.com>
Cc: pgsql-general@postgresql.org >> PG-General Mailing List <pgsql-general@postgresql.org>
Subject: Re: ora2pg and invalid command \N
Date: Fri, 16 Mar 2018 12:28:17 -0700
Message-ID: <1a55abfc-1656-1223-ecd7-ab69c1e8db7f@aklaver.com> (raw)
In-Reply-To: <CAPrg5cYk4_-Psn39ib-mMiTE10a_f=-AN4EPpyApxzPn=nMVug@mail.gmail.com>
References: <CAPrg5cY7+_h+Eonx2tLLvPHBa93PKPpO0MWpcK+AK0FtXF43rA@mail.gmail.com>
	<CAFj8pRA2WJ5P-phnY8DF-uf4LMJbMVNJeuZJ6AtvwBf9boudnA@mail.gmail.com>
	<CAPrg5cYk4_-Psn39ib-mMiTE10a_f=-AN4EPpyApxzPn=nMVug@mail.gmail.com>

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 <pavel.stehule@gmail.com 
> <mailto:pavel.stehule@gmail.com>> wrote:
> 
> 
> 
>     2018-03-16 18:12 GMT+01:00 Charlin Barak <charlinbarak@gmail.com
>     <mailto:charlinbarak@gmail.com>>:
> 
>         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
>     <https://stackoverflow.com/questions/4480381/postgres-sql-fail-on-script-error;
> 
>     Regards
> 
>     Pavel
> 
> 
>         Thanks.
> 
> 
> 
> 
> 
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com




view thread (6+ messages)  latest in thread

Message-ID: <1a55abfc-1656-1223-ecd7-ab69c1e8db7f@aklaver.com>
Permalink:  ../1a55abfc-1656-1223-ecd7-ab69c1e8db7f@aklaver.com/
Also on:    postgresql.org/message-id/1a55abfc-1656-1223-ecd7-ab69c1e8db7f@aklaver.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: adrian.klaver@aklaver.com, charlinbarak@gmail.com, pavel.stehule@gmail.com
  Subject: Re: ora2pg and invalid command \N
  In-Reply-To: <1a55abfc-1656-1223-ecd7-ab69c1e8db7f@aklaver.com>
  References: <CAPrg5cY7+_h+Eonx2tLLvPHBa93PKPpO0MWpcK+AK0FtXF43rA@mail.gmail.com> <CAFj8pRA2WJ5P-phnY8DF-uf4LMJbMVNJeuZJ6AtvwBf9boudnA@mail.gmail.com> <CAPrg5cYk4_-Psn39ib-mMiTE10a_f=-AN4EPpyApxzPn=nMVug@mail.gmail.com> <1a55abfc-1656-1223-ecd7-ab69c1e8db7f@aklaver.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox