X-Original-To: pgsql-odbc@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id A26374753A1 for ; Mon, 10 Feb 2003 19:26:58 -0500 (EST) Received: from sd.tpf.co.jp (sd.tpf.co.jp [210.161.239.34]) by postgresql.org (Postfix) with SMTP id 684D1474E53 for ; Mon, 10 Feb 2003 19:26:57 -0500 (EST) Received: (qmail 25472 invoked from network); 11 Feb 2003 00:26:59 -0000 Received: from unknown (HELO viscomail.tpf.co.jp) (100.0.0.108) by sd2.tpf-fw-c.co.jp with SMTP; 11 Feb 2003 00:26:59 -0000 Received: from tpf.co.jp (3dgateway1 [126.0.1.60]) by viscomail.tpf.co.jp (8.8.8+Sun/8.8.8) with ESMTP id JAA09130; Tue, 11 Feb 2003 09:26:58 +0900 (JST) Message-ID: <3E4843ED.27E84673@tpf.co.jp> Date: Tue, 11 Feb 2003 09:29:33 +0900 From: Hiroshi Inoue X-Mailer: Mozilla 4.73 [ja] (Windows NT 5.0; U) X-Accept-Language: ja MIME-Version: 1.0 To: Support Cc: pgsql-odbc@postgresql.org Subject: Re: error 23000 is not treated in psqlODBC References: <000901c2d12a$8b718720$1afaabc8@insyde> Content-Type: text/plain; charset=iso-2022-jp Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200302/52 X-Sequence-Number: 2670 Support wrote: > > "For example. you could have MS SQL Server and PostgreSQL servers > that have exactly the same data. Using ODBC, your Windows application > would make exactly the same calls and the back-end data source would > look the same (to the Windows application)." - PostgreSQL 7.2 > Documentation - chap. 7. ODBC Interface > > This should happen when I use my system. It works with MySQL and MS SQL > Server, so it would work with PostgreSQL also, without any change. The > problem I found is that psqlODBC do not validate all the error codes > specified by ODBC. The error I related should return "23000/S1010" > acording to ODBC. > > Seeking psqlODBC sources, I found some of this informations/errors were > treated at environ.c, under a 'case' where most of the psqlODBC errors > were treated. Following this logic, this is where I should insert > my code: > > case ER_DUP_KEY: > pg_sqlstate_set(env, szSqlState, "23000", "S1010"); > // key already exists > break; > > This would return the error code I need to treat qhe the user tries to > insert a duplicated key. Unfortunately PostgreSQL doesn't support error code at backend side and it's very hard for clients to detect error details such as *key already exists*. There may be a way where we analyze the error message but I won't do it. regards, Hiroshi Inoue http://www.geocities.jp/inocchichichi/psqlodbc/