X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id DDEB63A3CFB for ; Fri, 5 Nov 2004 16:20:48 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 71726-02 for ; Fri, 5 Nov 2004 16:20:40 +0000 (GMT) Received: from matrix.gatewaynet.com (matrix.gatewaynet.com [217.19.69.50]) by svr1.postgresql.org (Postfix) with ESMTP id 62CF83A3D36 for ; Fri, 5 Nov 2004 16:20:38 +0000 (GMT) Received: from matrix.gatewaynet.com (localhost.localdomain [127.0.0.1]) by matrix.gatewaynet.com (8.12.8/8.12.8) with ESMTP id iA5GoWb3012375; Fri, 5 Nov 2004 18:50:32 +0200 Received: from localhost (achill@localhost) by matrix.gatewaynet.com (8.12.8/8.12.8/Submit) with ESMTP id iA5GoWRL012371; Fri, 5 Nov 2004 18:50:32 +0200 Date: Fri, 5 Nov 2004 18:50:32 +0200 (EET) From: Achilleus Mantzios To: Flavio Fonseca Cc: pgsql-sql@postgresql.org Subject: Re: sql problem In-Reply-To: <200411051234.30961.ff@dr.ufu.br> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=ISO-8859-7 Content-Transfer-Encoding: 8BIT X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/48 X-Sequence-Number: 19367 O Flavio Fonseca έγραψε στις Nov 5, 2004 : > Hi, > > I am having a problem with a system I developed using php with postgres. > > Take a look at this: > > Welcome to psql 7.3.2, the PostgreSQL interactive terminal. > NetAdmin=# delete from operador where oplogin = 'ff'; > ERROR: fk_historicosessao_operador referential integrity violation - key in > operador still referenced from historicosessao > > and then, this: > > Welcome to psql 7.4.2, the PostgreSQL interactive terminal. > NetAdmin=# delete from operador where oplogin = 'ff'; > ERROR: update or delete on "operador" violates foreign key constraint > "fk_historicosessao_operador" on "historicosessao" > > I am not able to get a error_number in pgsql errors, only the error message. > So when I used pgsql 7.3 a used the string "referential integrity violation" > to detect this error, but on version 7.4 of pgsql this string was replaced > with "violates foreign key constraint" . > Anyone has a definitive solution on this or the way is to wait and change all > my code on future releases of pgsql? The right way to do so is to query for the SQLSTATE codes. For instance the jdbc7.4.6 driver supports sqlstate, which you can retrieve by sqle.getSQLState() That text of an Error may change across releases but the error code should be constant. p.s I dont do it my self. i just let my users educate themselves :) > > > Thank you all for the attention. > -- -Achilleus