pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ian Barwick <barwick@gmx.net>
To: postgres@yahoogroups.de, Danny Tramnitzke <vadus@gmx.de>
Subject: Re: [postgres] Copy Timestamp NULL
Date: Fri, 10 Oct 2003 21:08:59 +0200
Message-ID: <200310102108.59428.barwick@gmx.net> (raw)
In-Reply-To: <oprwrmyng33tnzk7@smtp.gmx.de>
References: <oprt846vkx3tnzk7@smtp.gmx.de>
	<2153510000.1061474229@gnarzelwicht.delirium-arts.de>
	<oprwrmyng33tnzk7@smtp.gmx.de>

On Thursday 09 October 2003 09:55, Danny Tramnitzke wrote:
(...)
> Also es geht darum, dass ich in eine Postgres Tabelle per Copy Daten laden
> möchte.
> Bei einer Spalte handelt es sich um Timestamp NULL ... In der Source-Datei
> befinden sich in dieser Spalte ISO Timestamp Werte und NULL - Werte .
> (Nicht jede Zeile besitzt einen Timestamp-wert)
>
> Die Source-Datei sieht prinzipiell so aus :
>
> 1|Hallo|17.0|1999-01-23 14:30:08.456234|usr01
> 2|Test|18.5||usr02
>
> Die Spalte 4 ist somit vom Typ Timestamp.
>
> Allerdings kann ich diese Source-Datei nicht in die Postgres Tabelle per
> Copy laden, da es an den NULL - Stellen zum Fehler kommt : Bad timestamp
> external representation ''
>
> Wenn also eine "Lücke" gefunden wird, interpretiert Copy diese "Lücke"
> nicht als Null-Wert und beschwert sich über das fehlerhafte Timestamp
> Format.
>
> Es geht ebenfalls nicht, wenn ich an der entsprechenden Stelle NULL
> schreibe.
>
> Was muss ich also angeben, damit ich solch eine Datei laden kann ?

Ich nehme an, Du fuehrst in etwa folgendes aus:

COPY x FROM '/pfad/zur/datei' DELIMITER '|';

Da musst Du dann in den Spalten mit einem NULL-Wert \N einfügen, also:

  2|Test|18.5|\N|usr02

Das kann auch ein anderer Wert sein, z.B.

COPY x FROM '/pfad/zur/datei' DELIMITER '|' NULL 'NULL';

um NULL schreiben zu koennen. Die relevante Stelle in der Dokumentation
ist hier:

http://www.postgresql.org/docs/7.3/static/sql-copy.html

mfg

Ian Barwick

--
barwick@gmx.net
http://www.postgresql.org/docs/faqs/FAQ_german.html
http://sql-info.de/postgresql/de/

Wenn Sie Ihr Abonnement fuer diese Gruppe kuendigen moechten, senden 
Sie eine E-Mail an:
postgres-unsubscribe@egroups.de

 

Die Nutzung von Yahoo! Groups ist Bestandteil von http://de.docs.yahoo.com/info/utos.html 





view thread (2+ messages)

Message-ID: <200310102108.59428.barwick@gmx.net>
Permalink:  ../200310102108.59428.barwick@gmx.net/
Also on:    postgresql.org/message-id/200310102108.59428.barwick@gmx.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: barwick@gmx.net, vadus@gmx.de
  Subject: Re: [postgres] Copy Timestamp NULL
  In-Reply-To: <200310102108.59428.barwick@gmx.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox