Re: COPY doesn't like my dates on STDIN

Поиск
Список
Период
Сортировка
От James Long
Тема Re: COPY doesn't like my dates on STDIN
Дата
Msg-id 20080319054119.GA70595@ns.umpquanet.com
обсуждение исходный текст
Ответ на COPY doesn't like my dates on STDIN  (James Long <pgsql-novice@museum.rain.com>)
Список pgsql-novice
My bad, I apologize.  The error was not being thrown by the
COPY statement, but by a later INSERT.

The syslog showed me this:

Mar 18 22:32:02 ns postgres[70347]: [6-1] ERROR:  syntax error at or near "2008" at character 1
Mar 18 22:32:02 ns postgres[70347]: [6-2] STATEMENT:  2008-03-18
Mar 18 22:32:02 ns postgres[70347]: [6-3]       insert into table_name
Mar 18 22:32:02 ns postgres[70347]: [6-4]       select * from temp_table;

I thought that INSERT would match up like-named fields, but
it appears to match fields up in the order they appear in
the schema.  If suppose to match up like names, one
must specify the ( field, names ) in the INSERT and SELECT
statements.

Jim


On Tue, Mar 18, 2008 at 08:31:41PM -0700, James Long wrote:
> I'm trying to
>
> copy temp_table ( id, date_created ) from stdin;
> TME     2008-03-18
> \.
>
> pgsql says:
>
> ERROR:  column "date_created" is of type date but expression is of type character
> HINT:  You will need to rewrite or cast the expression.
>
> I basically grok what it is saying, but the "expression" is in the
> STDIN stream.  How do I cast that?  And I also don't get why my
> pg_dump backup scripts use this same syntax but I can't.
>
> One such pg_dump-created file says:
>
> COPY tickets (ticket_number, reservation_number, travel_date, issue_date, ... )
> FROM stdin;
> 2115492091826   11ACFD  2006-08-28      \N      ...
>
> Certainly, no criticism intended.  I really enjoy PG.  Just
> confusion on my part is all.
>
> Thank you,
>
> Jim
>
> --
> Sent via pgsql-novice mailing list (pgsql-novice@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-novice

В списке pgsql-novice по дате отправления:

Предыдущее
От: James Long
Дата:
Сообщение: COPY doesn't like my dates on STDIN
Следующее
От: "G. J. Walsh"
Дата:
Сообщение: Re: Database Classes and prepared statements