Error in using the COPY command

1

Good evening Community:

I try to execute the following statement in PostgreSQL:

COPY ad_alert (ad_alert_id, ad_client_id, ad_org_id, isactive) FROM stdin;
               100       0            0      N  

And it throws me an error at or near 100.

Is there something wrong with my sentence copy ?

Thanks for your help.

    
asked by David Leandro Heinze Müller 09.11.2016 в 04:16
source

1 answer

1

PgAdmin is not able to execute copy ... from stdin . I suggest 2 alternatives:

  • If you want to use PgAdmin , I suggest you copy the data you want to a file (say c:\test.dat for example) and execute the following sentence:

    COPY ad_alert (ad_alert_id, ad_client_id, ad_org_id, isactive) FROM 'c:\test.dat';
    
  • Use psql instead of PgAdmin . Using psql you can execute the following statement:

    db=# copy ad_alert(ad_alert_id, ad_client_id, ad_org_id, isactive) from stdin;
    Enter data to be copied followed by a newline.
    End with a backslash and a period on a line by itself.
    >> 100  0       0       N
    >> \.
    COPY 1
    
  • Additional note

    If you decide to use the first option by copying the data to a file, be careful with the file format. In particular, avoid saving it in UTF-8 with BOM . I made this mistake, and it did not work properly because the file contained the BOM character at the beginning ( U+FEFF ). And I think I remember from a past question of yours that you've already had problems with that character in one of your files. That's why I mention it just in case.

        
    answered by 09.11.2016 / 04:41
    source