X-Original-To: pgsql-interfaces-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id D21059DCA04 for ; Fri, 6 Jan 2006 00:20:19 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 91126-01 for ; Fri, 6 Jan 2006 00:20:18 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from smtp-vbr4.xs4all.nl (smtp-vbr4.xs4all.nl [194.109.24.24]) by postgresql.org (Postfix) with ESMTP id 22F0A9DC947 for ; Fri, 6 Jan 2006 00:20:16 -0400 (AST) Received: from webmail.xs4all.nl (dovemail7.xs4all.nl [194.109.26.9]) by smtp-vbr4.xs4all.nl (8.13.3/8.13.3) with ESMTP id k064JoMp028954; Fri, 6 Jan 2006 05:19:55 +0100 (CET) (envelope-from jtv@xs4all.nl) Received: from 125.24.3.239 (SquirrelMail authenticated user jtv) by webmail.xs4all.nl with HTTP; Fri, 6 Jan 2006 11:19:56 +0700 (ICT) Message-ID: <7738.125.24.3.239.1136521196.squirrel@webmail.xs4all.nl> 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> Date: Fri, 6 Jan 2006 11:19:56 +0700 (ICT) Subject: Re: [C API] Is there a nice way to get table/column From: "Jeroen T. Vermeulen" To: "Michael Fuhr" Cc: "JiangWei" , pgsql-interfaces@postgresql.org User-Agent: SquirrelMail/1.4.5 MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: by XS4ALL Virus Scanner X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.06 required=5 tests=[AWL=0.060] X-Spam-Score: 0.06 X-Spam-Level: X-Archive-Number: 200601/7 X-Sequence-Number: 5923 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