|
Home > Archive > PostgreSQL Interfaces > January 2006 > Re: [C API] Is there a nice way to get table/column name on some error ?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Re: [C API] Is there a nice way to get table/column name on some error ?
|
|
| Michael Fuhr 2006-01-05, 8:25 pm |
| [Please post in plain text, not HTML.]
On Fri, Jan 06, 2006 at 09:32:36AM +0800, JiangWei wrote:
> 42703 UNDEFINED COLUMN undefined_column
> 42883 UNDEFINED FUNCTION undefined_function
> 42P01 UNDEFINED TABLE undefined_table
>
> I want to know which column undefined when "undefined_column" Happen
> at run time.
With libpq you can call PQerrorMessage(), PQresultErrorMessage
(),
or PQresultErrorField()
to get a string that should identify the
offending column, function, table, etc. Will that work for your
purpose?
--
Michael Fuhr
---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster
| |
| Michael Fuhr 2006-01-06, 3:24 am |
| [Please post in plain text, not HTML.]
On Fri, Jan 06, 2006 at 10:15:19AM +0800, JiangWei wrote:
>
> No. I want to throw a exception with the column name, like this :
> if (sqlstate == undefined_column)
> throw UnknownProperty(colu
mn_name);
I'm not aware of a way to get just the column name, so if nobody
else posts a way then you might have to parse the error message
(admittedly a pain, especially if you have to deal with different
languages).
--
Michael Fuhr
---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql
.org so that your
message can get through to the mailing list cleanly
|
|
|
|
|