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

From: "Jeroen T(dot) Vermeulen" <jtv(at)xs4all(dot)nl>
To: "Michael Fuhr" <mike(at)fuhr(dot)org>
Cc: "JiangWei" <jw(dot)pgsql(at)sduept(dot)com>, pgsql-interfaces(at)postgresql(dot)org
Subject: Re: [C API] Is there a nice way to get table/column
Date: 2006-01-06 04:19:56
Message-ID: 7738.125.24.3.239.1136521196.squirrel@webmail.xs4all.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-interfaces by date

  From Date Subject
Next Message JiangWei 2006-01-06 04:45:36 Re: [C API] Is there a nice way to get table/column
Previous Message Michael Fuhr 2006-01-06 04:01:58 Re: [C API] Is there a nice way to get table/column name on some error ?