pg.ddx.io pgsql-interfaces@postgresql.org mailing list archive
help / color / mirror / Atom feed[C API] Is there a nice way to get table/column name on some error ?
3+ messages / 2 participants
[nested] [flat]
* [C API] Is there a nice way to get table/column name on some error ?
@ 2006-01-06 01:32 JiangWei <jw.pgsql@sduept.com>
2006-01-06 02:11 ` Re: [C API] Is there a nice way to get table/column name on some error ? Michael Fuhr <mike@fuhr.org>
0 siblings, 1 reply; 3+ messages in thread
From: JiangWei @ 2006-01-06 01:32 UTC (permalink / raw)
To: pgsql-interfaces
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
<table class="CALSTABLE" border="1">
<tbody>
<tr>
<td>42703</td>
<td>UNDEFINED COLUMN</td>
<td>undefined_column</td>
</tr>
<tr>
<td>42883</td>
<td>UNDEFINED FUNCTION</td>
<td>undefined_function</td>
</tr>
<tr>
<td>42P01</td>
<td>UNDEFINED TABLE</td>
<td>undefined_table</td>
</tr>
</tbody>
</table>
<br>
I want to know which column undefined when "undefined_column" Happen at
run time.<br>
<br>
<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 name on some error ?
2006-01-06 01:32 [C API] Is there a nice way to get table/column name on some error ? JiangWei <jw.pgsql@sduept.com>
@ 2006-01-06 02:11 ` Michael Fuhr <mike@fuhr.org>
2006-01-06 04:01 ` Re: [C API] Is there a nice way to get table/column name on some error ? Michael Fuhr <mike@fuhr.org>
0 siblings, 1 reply; 3+ messages in thread
From: Michael Fuhr @ 2006-01-06 02:11 UTC (permalink / raw)
To: JiangWei <jw.pgsql@sduept.com>; +Cc: pgsql-interfaces
[Please post in plain text, not HTML.]
On Fri, Jan 06, 2006 at 09:32:36AM +0800, JiangWei wrote:
> 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.
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?
--
Michael Fuhr
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: [C API] Is there a nice way to get table/column name on some error ?
2006-01-06 01:32 [C API] Is there a nice way to get table/column name on some error ? JiangWei <jw.pgsql@sduept.com>
2006-01-06 02:11 ` Re: [C API] Is there a nice way to get table/column name on some error ? Michael Fuhr <mike@fuhr.org>
@ 2006-01-06 04:01 ` Michael Fuhr <mike@fuhr.org>
0 siblings, 0 replies; 3+ messages in thread
From: Michael Fuhr @ 2006-01-06 04:01 UTC (permalink / raw)
To: JiangWei <jw.pgsql@sduept.com>; +Cc: pgsql-interfaces
[Please post in plain text, not HTML.]
On Fri, Jan 06, 2006 at 10:15:19AM +0800, JiangWei wrote:
> > 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?
>
> 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).
--
Michael Fuhr
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2006-01-06 04:01 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 01:32 [C API] Is there a nice way to get table/column name on some error ? JiangWei <jw.pgsql@sduept.com>
2006-01-06 02:11 ` Michael Fuhr <mike@fuhr.org>
2006-01-06 04:01 ` Michael Fuhr <mike@fuhr.org>
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