Received: from localhost (unknown [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 685B82E0359 for ; Thu, 28 Feb 2008 15:11:31 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 99037-02-2 for ; Thu, 28 Feb 2008 15:11:14 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from fmailhost04.isp.att.net (fmailhost04.isp.att.net [207.115.11.54]) by postgresql.org (Postfix) with ESMTP id 8DB8A2E266B for ; Thu, 28 Feb 2008 15:10:50 -0400 (AST) Received: from [192.168.100.100] (adsl-144-170-195.mia.bellsouth.net[72.144.170.195]) by isp.att.net (frfwmhc04) with SMTP id <20080228191048H0400a35qbe>; Thu, 28 Feb 2008 19:10:48 +0000 X-Originating-IP: [72.144.170.195] Message-Id: <650E1D02-A244-44F4-81A4-5977F8D879E8@dsgi.us> From: Alex Hochberger To: pgsql-sql@postgresql.org Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v919.2) Subject: pl/pgsql and error handling Date: Thu, 28 Feb 2008 14:10:47 -0500 X-Mailer: Apple Mail (2.919.2) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200802/234 X-Sequence-Number: 30325 Is it possible to grab access to the actually user-friendly error message? I have a bunch of files that come into my database, each slightly different. The submitter fills out a form that records the info, and sticks it into a table. If the file is malformed (wrong number of columns in a row) from a missing comma or something, I want to record the result to store in the database. I assume that I should exception handle the COPY FROM line, and store the results, but I can't for the life of me figure out how to get the text like "invalid line on line 470352" or whatever psql shows. Is that possible to obtain in plpgsql? I've done extensive plpgsql programming before, but this is the first time I need it to validate the external data in question. Alex