From: Michael Fuhr <mike@fuhr.org>
To: JiangWei <jw.pgsql@sduept.com>
Cc: pgsql-interfaces@postgresql.org
Subject: Re: [C API] Is there a nice way to get table/column name on some error ?
Date: Thu, 5 Jan 2006 21:01:58 -0700
Message-ID: <20060106040158.GA81499@winnie.fuhr.org> (raw)
In-Reply-To: <43BDD2B7.2090609@sduept.com>
References: <43BDC8B4.6020801@sduept.com>
<20060106021149.GA80657@winnie.fuhr.org>
<43BDD2B7.2090609@sduept.com>
[Please post in plain text, not HTML.]
On Fri, Jan 06, 2006 at 10:15:19AM +0800, JiangWei wrote:
> > 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?
>
> No. I want to throw a exception with the column name, like this :
> if (sqlstate == undefined_column)
> throw UnknownProperty(column_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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-interfaces@postgresql.org
Cc: mike@fuhr.org, jw.pgsql@sduept.com
Subject: Re: [C API] Is there a nice way to get table/column name on some error ?
In-Reply-To: <20060106040158.GA81499@winnie.fuhr.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox