Re: sql problem

From: Achilleus Mantzios <achill(at)matrix(dot)gatewaynet(dot)com>
To: Flavio Fonseca <ff(at)dr(dot)ufu(dot)br>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: sql problem
Date: 2004-11-05 16:50:32
Message-ID: Pine.LNX.4.44.0411051820490.12273-100000@matrix.gatewaynet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

In response to

  • sql problem at 2004-11-05 14:34:30 from Flavio Fonseca

Browse pgsql-sql by date

  From Date Subject
Next Message Andras Kutrovics 2004-11-05 16:54:41 Simple SQL Question
Previous Message Tom Lane 2004-11-05 16:02:28 Re: Killed backend won't rollback transaction?