Re: How to determine offending column for insert exceptions - Mailing list pgsql-sql

From s d
Subject Re: How to determine offending column for insert exceptions
Date
Msg-id CAKyoTgbNyknV8NUARrLeLHmScXG6htrB6OhjwPLK4kqTzQWsNw@mail.gmail.com
Whole thread Raw
In response to Re: How to determine offending column for insert exceptions  (Shawn Gennaria <sgennaria2@gmail.com>)
List pgsql-sql
I'm not sure, but I have a guess, why the column_name is null.
You wrote your queries look like this:

INSERT INTO final_table
SELECT a::int, b::int FROM temp_table

The error comes from the result expression of the select statement where the source column can't be determined exactly.

Regards,
Sándor Daku


On 21 April 2015 at 18:48, Shawn Gennaria <sgennaria2@gmail.com> wrote:
Glad to hear it's here just in time.  I am using 9.4, though, so I wish I could figure out why it's returning NULL when I use it.  And the error message string doesn't contain any column name to parse in my output.

On Tue, Apr 21, 2015 at 12:46 PM, Alvaro Herrera <alvherre@2ndquadrant.com> wrote:
Shawn Gennaria wrote:
> OK, I'm looking at
> www.postgresql.org/docs/9.4/interactive/plpgsql-control-structures.html#PLPGSQL-EXCEPTION-DIAGNOSTICS-VALUES
> which I completely missed before.  This sounds like my answer, but it's not
> returning anything when I try to extract the COLUMN_NAME.

As far as I recall, COLUMN_NAME is new in 9.4.  If you're trying with an
earlier version, you can't get that info other than by parsing the error
message string.


--
Álvaro Herrera                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


pgsql-sql by date:

Previous
From: Seth Gordon
Date:
Subject: Re: How to determine offending column for insert exceptions
Next
From: Shawn Gennaria
Date:
Subject: Re: How to determine offending column for insert exceptions