Re: [C API] Is there a nice way to get table/column

Поиск
Список
Период
Сортировка
От Jeroen T. Vermeulen
Тема Re: [C API] Is there a nice way to get table/column
Дата
Msg-id 7738.125.24.3.239.1136521196.squirrel@webmail.xs4all.nl
обсуждение исходный текст
Ответ на Re: [C API] Is there a nice way to get table/column name on some error ?  (Michael Fuhr <mike@fuhr.org>)
Ответы Re: [C API] Is there a nice way to get table/column  (JiangWei <jw.pgsql@sduept.com>)
Список 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 по дате отправления:

Предыдущее
От: Michael Fuhr
Дата:
Сообщение: Re: [C API] Is there a nice way to get table/column name on some error ?
Следующее
От: JiangWei
Дата:
Сообщение: Re: [C API] Is there a nice way to get table/column