pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jeroen T. Vermeulen <jtv@xs4all.nl>
To: Michael Fuhr <mike@fuhr.org>
Cc: JiangWei <jw.pgsql@sduept.com>
Cc: pgsql-interfaces@postgresql.org
Subject: Re: [C API] Is there a nice way to get table/column
Date: Fri, 6 Jan 2006 11:19:56 +0700 (ICT)
Message-ID: <7738.125.24.3.239.1136521196.squirrel@webmail.xs4all.nl> (raw)
In-Reply-To: <20060106040158.GA81499@winnie.fuhr.org>
References: <43BDC8B4.6020801@sduept.com>
	<20060106021149.GA80657@winnie.fuhr.org>
	<43BDD2B7.2090609@sduept.com>
	<20060106040158.GA81499@winnie.fuhr.org>

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





view thread (3+ messages)  latest in thread

Message-ID: <7738.125.24.3.239.1136521196.squirrel@webmail.xs4all.nl>
Permalink:  ../7738.125.24.3.239.1136521196.squirrel@webmail.xs4all.nl/
Also on:    postgresql.org/message-id/7738.125.24.3.239.1136521196.squirrel@webmail.xs4all.nl

 · 

reply

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: jtv@xs4all.nl, mike@fuhr.org, jw.pgsql@sduept.com
  Subject: Re: [C API] Is there a nice way to get table/column
  In-Reply-To: <7738.125.24.3.239.1136521196.squirrel@webmail.xs4all.nl>

* 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