X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C605453CB2 for ; Fri, 8 Apr 2005 19:12:41 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 01201-04 for ; Fri, 8 Apr 2005 18:12:32 +0000 (GMT) Received: from mail.99main.com (mail.99main.com [208.28.184.11]) by svr1.postgresql.org (Postfix) with ESMTP id 3C9E253C9D for ; Fri, 8 Apr 2005 19:12:15 +0100 (BST) Received: from 99main.com (localhost [127.0.0.1]) by mail.99main.com (8.12.8+Sun/8.12.8) with ESMTP id j38ICBjj005542; Fri, 8 Apr 2005 14:12:11 -0400 (EDT) From: "Keith Worthington" To: Stef , pgsql-sql@postgresql.org Reply-To: KeithW@narrowpathinc.com Subject: Re: Numeric and CSV under 8.0.1 ? Date: Fri, 8 Apr 2005 14:12:11 -0400 Message-Id: <20050408181148.M49002@narrowpathinc.com> In-Reply-To: <20050408165147.GV30669@survivor.hades> References: <20050408165147.GV30669@survivor.hades> X-Mailer: Open WebMail 2.50 20050106 X-OriginatingIP: 68.235.22.242 (npkeithw) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200504/106 X-Sequence-Number: 20999 On Fri, 8 Apr 2005 12:51:47 -0400, Stef wrote > Hello Everyone, > Currently, here at work, I am doing the whole > 'advocacy' part of postgreSQL. It's not really hard to > do, as the other database's are MySQL and Sybase ;) > > There is obviously a whole spat of data munging > going on in the background, and I noticed that psql in > 8.0.1 now accepts CSV ! Great. > > Except, it doesn't really appear to be 100% there. > Numeric's wrapped in '...' don't want to appear to go in. > Is this a 'known problem' ? > > Table "public.visitor_main" > Column | Type | Modifiers > > ------------------+----------------------+------------------------------ > iuserid | numeric(12,0) | not null > firstname | character(25) | not null > lastname | character(25) | not null > > Sample Data line > '3236','Alonzo','Peter' > > ERROR: invalid input syntax for type numeric: "'3236'" > CONTEXT: COPY visitor_main, line 1, column iuserid: "'3236'" > > Thoughts ? > Regards > Steph Steph, '3236' is a string not a numeric. As I see it (novice that I am) you have three choices. 1) Write an external program (gawk, sed, etc.) to remove the quotes around that field. 2) Import the data into an intermediate table and then using an after trigger move and manipulate the data using CAST. 3) Import the data into your table using a BEFORE trigger and manipulate the data using CAST. HTH Kind Regards, Keith