Re: Copy from : ERROR: date/time field value out of range

From: Jean-Paul Argudo <jean-paul(at)argudo(dot)org>
To: David Tokmatchi <david(dot)tokmatchi(at)gmail(dot)com>
Cc: pgsql-fr-generale(at)postgresql(dot)org
Subject: Re: Copy from : ERROR: date/time field value out of range
Date: 2007-07-30 14:57:38
Message-ID: 46ADFC62.6060002@argudo.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-fr-generale

Bonjour,

$ psql < create_table.sql
CREATE TABLE

(recréé à partir de votre description)

jpargudo=# show datestyle ;
DateStyle
-----------
ISO, DMY
(1 ligne)

jpargudo=# copy toto from
'/home/jpargudo/PostgreSQL/misc/copy_problem/data.txt' delimiters '~';

COPY 8

jpargudo=# select * from toto ;
to_ref | to_entity | to_date
| to_time | to_occ
---------+------------------------------------------+---------------------+---------------------+--------
3454495 | TQKQD | 2007-03-12
00:00:00 | 1900-01-01 17:35:26 |
3454496 | HHKKF | 2007-03-12
00:00:00 | 1900-01-01 17:35:34 |
3454497 | BBIIL | 2007-03-12
00:00:00 | 1900-01-01 17:35:39 |
3454501 | IKKFFS | 2007-03-12
00:00:00 | 1900-01-01 17:43:16 |
3454502 | ADJUSTMENT | 2007-03-12
00:00:00 | 1900-01-01 17:44:33 |
3454503 | ADJUSTMENT | 2007-03-12
00:00:00 | 1900-01-01 17:46:16 |
3454504 | ADJUSTMENT | 2007-03-12
00:00:00 | 1900-01-01 17:47:52 |
3454517 | TFFFR | 2007-03-13
00:00:00 | 1900-01-01 08:53:20 |
(8 lignes)

Tout est ok.

Pouvez-vous vérifier cela:

jpargudo=# show datestyle ;
DateStyle
-----------
ISO, DMY
(1 ligne)

Si vous n'avez pas cela, mais par exemple MDY, comme je le soupçonne, on
tombe sur les messages d'erreurs que vous avez:

jpargudo=# set datestyle TO 'MDY';
SET

jpargudo=# copy toto from
'/home/jpargudo/PostgreSQL/misc/copy_problem/data.txt' delimiters '~';

ERREUR: Valeur du champ date/time en dehors des limites : «13.03.2007
00:00:00»
HINT: Peut-être avez-vous besoin d'un paramétrage «datestyle» différent.
CONTEXT: COPY toto, ligne 8, colonne to_date : «13.03.2007 00:00:00»

Mon avis, c'est que le paramétrage des "locales" de votre serveur n'est
pas fait, que vous avez probablement tout en langue "C" par défaut. Du
coup, vous *devrez* spécifier le DATESTYLE, comme on vous l'indique.

Par exemple, comparer le résultat de cette requête avec votre installation:

jpargudo=# select name, setting from pg_settings where name ~* 'lc';
name | setting
-------------+-------------
lc_collate | fr_FR.UTF-8
lc_ctype | fr_FR.UTF-8
lc_messages | fr_FR.UTF-8
lc_monetary | fr_FR.UTF-8
lc_numeric | fr_FR.UTF-8
lc_time | fr_FR.UTF-8
(6 lignes)

Je suis prêt à parier que vous avez des "C" partout, n'est-ce pas?

--
Jean-Paul Argudo
http://www.dalibo.com
http://www.PostgreSQLFr.org

In response to

Browse pgsql-fr-generale by date

  From Date Subject
Next Message Jean-Christophe Arnu 2007-07-30 14:59:24 Re: Copy from : ERROR: date/time field value out of range
Previous Message Jean-Christophe Arnu 2007-07-30 14:46:54 Re: Reponse lente de postgres