pl/pgsql and error handling

From: Alex Hochberger <alex(at)dsgi(dot)us>
To: pgsql-sql(at)postgresql(dot)org
Subject: pl/pgsql and error handling
Date: 2008-02-28 19:10:47
Message-ID: 650E1D02-A244-44F4-81A4-5977F8D879E8@dsgi.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2008-02-29 04:43:05 Re: pl/pgsql and error handling
Previous Message Professor Flávio Brito 2008-02-28 16:01:41 Re: Function returns error (view) (RESOLVED)