Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search for
  Advanced Search

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



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





Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group