Erro ´violation of PRIMARY or UNIQUE KEY...´ - alguém sabe ?

Delphi

27/02/2004

Olá,

Estou trabalhando com FireBird, tenho uma tabela OPERADOR_CAIXA que tem somente declarado a PRIMARY KEY como no exemplo:

/* Table: OPERADOR_CAIXA, Owner: SYSDBA */

CREATE TABLE ´OPERADOR_CAIXA´
(
´CODIGO´INTEGER NOT NULL,
´NOME´VARCHAR(45),
´SUPERVISOR´CHAR(1),
´SENHA´VARCHAR(5),
PRIMARY KEY (´CODIGO´)
);

no evento OnPostError do ClientDataSet estou tratando registro duplicado(KEY VIOLATION) da seguinte forma:

begin
if E.Message=´violation of PRIMARY or UNIQUE KEY constraint ´INTEG_2´ on table ´OPERADOR_CAIXA´´ then
begin
MessageDlg(´Sua mensagem de erro!´,mterror,[mbok],0);
Action := daAbort;
end;
END;
... e quando rodo o programa ele dá o seguinte erro:

´violation of PRIMARY or UNIQUE KEY constraint ´INTEG_2´ on table ´OPERADOR_CAIXA´´.

O que faço ????


Sergiom

Sergiom

Curtidas 1

Respostas

Sremulador

Sremulador

27/02/2004

Amigo você deve estar tentando inserir um cod já existente em sua tabela


GOSTEI 0
Sergiom

Sergiom

27/02/2004

Com certeza, o que eu preciso é exatamente tratar esse tipo de erro


GOSTEI 0
POSTAR