Re: [C API] Is there a nice way to get table/column - Mailing list pgsql-interfaces

From Jeroen T. Vermeulen
Subject Re: [C API] Is there a nice way to get table/column
Date
Msg-id 7738.125.24.3.239.1136521196.squirrel@webmail.xs4all.nl
Whole thread Raw
In response to Re: [C API] Is there a nice way to get table/column name on some error ?  (Michael Fuhr <mike@fuhr.org>)
Responses Re: [C API] Is there a nice way to get table/column
List pgsql-interfaces
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




pgsql-interfaces by date:

Previous
From: Michael Fuhr
Date:
Subject: Re: [C API] Is there a nice way to get table/column name on some error ?
Next
From: JiangWei
Date:
Subject: Re: [C API] Is there a nice way to get table/column