On Fri, January 6, 2006 11:01, Michael Fuhr wrote:
> 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(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).
Well, assuming your program has a hand in constructing the queries and
therefore understands their structure, you could have a pretty good stab
at finding out.
Just query the system catalog to find the invalid column name. It'd be
slow, but exceptions are presumably rare so the cost may be acceptable.
(BTW apparently you're using C++, not C, so why are you using the C API?)
Jeroen