Handling SQL errors using libpq
| От | brennan@unix2.netaxs.com (William Brennan) |
|---|---|
| Тема | Handling SQL errors using libpq |
| Дата | |
| Msg-id | nJ9D9.575$cX3.467535@newshog.newsread.com обсуждение исходный текст |
| Ответы |
Re: Handling SQL errors using libpq
|
| Список | pgsql-interfaces |
I'm new to Postgresql, so please bear with me. After a call to libpq, I would like to be able to recognize specific SQL errors which might occur, beyond the simple results obtainable via a call to PQresultStatus(). I want more precision. For example, I have a table with a primary key. If I attempt to insert a new row with a duplicate key, PQresultStatus() rightly returns an error (PGRES_FATAL_ERROR). However my program has no way to distinguish from this blunt instrument whether it's a duplicate-key problem, or any of hundreds of other problems. How should my program recognize the duplicate-key error? And more generally, how to I reconize other anticipated SQL errors? Thanks for your help! -- Bill
В списке pgsql-interfaces по дате отправления: