Re: using COPY table FROM STDIN within script run as psql

Поиск
Список
Период
Сортировка
Искать
От
Bruce Momjian
Тема
Re: using COPY table FROM STDIN within script run as psql
Дата
Msg-id
200409260106.i8Q16j313474@candle.pha.pa.us
Ответ на
Список
Дерево обсуждения
using COPY table FROM STDIN within script run as psql -f file.sql Kevin Murphy <murphy@genome.chop.edu>
Re: using COPY table FROM STDIN within script run as psql Bruce Momjian <pgman@candle.pha.pa.us>
Re: using COPY table FROM STDIN within script run as psql Kevin Murphy <murphy@genome.chop.edu>
Re: using COPY table FROM STDIN within script run as psql Tom Lane <tgl@sss.pgh.pa.us>
Re: using COPY table FROM STDIN within script run as psql Kevin Murphy <murphy@genome.chop.edu>


Would you provide a reproducable example?  Also, what PostgreSQL version
are you using?

---------------------------------------------------------------------------

Kevin Murphy wrote:
> This is a tip for the record in case it helps somebody else in the 
> future.
> 
> I have an import script that relies on a stored procedure that runs as 
> a trigger on inserts into a temporary table.  The script looks like 
> this:
> 
> -- create table
> -- ...
> -- define procedure and trigger
> -- ...
> -- import data via COPY command:
> COPY temp_table FROM STDIN WITH NULL AS '';
> 
> However, when run as "psql -f import.sql  if you use the SQL "COPY" command, even if you are running psql on the 
> database server.  You get an error like this: ERROR:  missing data for 
> column "somecol".  An interesting red-herring is that the column 
> mentioned is not necessarily the first column in the table!
> 
> The solution is to use the psql "\COPY" command instead (and remove the 
> trailing semi-colon, which cannot be used with psql commands).  I.e. 
> this command will work:
> 
> \COPY temp_table FROM STDIN WITH NULL AS '';
> 
> -Kevin Murphy
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
> 

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
В списке pgsql-general по дате отправления
От: Doug McNaught
Дата:
Сообщение: Re: serial data type
От: Bruce Momjian
Дата:
Сообщение: Re: R?f. : Re: v8 on AIX5.2
FAQ