pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Re: [C API] Is there a nice way to get table/column
3+ messages / 2 participants
[nested] [flat]

* Re: [C API] Is there a nice way to get table/column
@ 2006-01-06 02:15  JiangWei <jw.pgsql@sduept.com>
  0 siblings, 1 reply; 3+ messages in thread

From: JiangWei @ 2006-01-06 02:15 UTC (permalink / raw)
  To: Michael Fuhr <mike@fuhr.org>; +Cc: pgsql-interfaces

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Michael Fuhr wrote:
<blockquote cite="mid20060106021149.GA80657@winnie.fuhr.org" type="cite">
  <pre wrap="">[Please post in plain text, not HTML.]

On Fri, Jan 06, 2006 at 09:32:36AM +0800, JiangWei wrote:
  </pre>
  <blockquote type="cite">
    <pre wrap="">42703 UNDEFINED COLUMN   undefined_column
42883 UNDEFINED FUNCTION undefined_function
42P01 UNDEFINED TABLE    undefined_table

I want to know which column undefined when "undefined_column" Happen
at run time.
    </pre>
  </blockquote>
  <pre wrap=""><!---->
With libpq you can call PQerrorMessage(), PQresultErrorMessage(),
or PQresultErrorField() to get a string that should identify the
offending column, function, table, etc.  Will that work for your
purpose?

  </pre>
</blockquote>
No.&nbsp; I want to throw a exception with&nbsp; the column name, like this :<br>
<br>
if (sqlstate == undefined_column)<br>
&nbsp; throw UnknownProperty(column_name);<br>
<br>
<br>
</body>
</html>



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: [C API] Is there a nice way to get table/column
@ 2006-01-06 04:19  Jeroen T. Vermeulen <jtv@xs4all.nl>
  parent: JiangWei <jw.pgsql@sduept.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Jeroen T. Vermeulen @ 2006-01-06 04:19 UTC (permalink / raw)
  To: Michael Fuhr <mike@fuhr.org>; +Cc: 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





^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: [C API] Is there a nice way to get table/column
@ 2006-01-06 04:45  JiangWei <jw.pgsql@sduept.com>
  parent: Jeroen T. Vermeulen <jtv@xs4all.nl>
  0 siblings, 0 replies; 3+ messages in thread

From: JiangWei @ 2006-01-06 04:45 UTC (permalink / raw)
  To: ; +Cc: pgsql-interfaces


>(BTW apparently you're using C++, not C, so why are you using the C API?)
>
>
>Jeroen
>
>
>
>  
>
C API is simple,clean



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2006-01-06 04:45 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-01-06 02:15 Re: [C API] Is there a nice way to get table/column JiangWei <jw.pgsql@sduept.com>
2006-01-06 04:19 ` Jeroen T. Vermeulen <jtv@xs4all.nl>
2006-01-06 04:45   ` JiangWei <jw.pgsql@sduept.com>

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