Violation of Primary or Unique Key

Delphi

01/03/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 ????

[color=red:2b554ad85c][b:2b554ad85c]Editado(Beppe): VIOLATION OF PRIMARY OR UNIQUE KEY...Socorro...como resolvo? - Leia as regras de conduta[/b:2b554ad85c][/color:2b554ad85c]


Sergiom

Sergiom

Curtidas 0

Respostas

Buosinet

Buosinet

01/03/2004

Podem ser os apostrofos. Tente:

if E.Message=QuotedStr(´violation of PRIMARY or UNIQUE KEY constraint ´INTEG_2´ on table ´OPERADOR_CAIXA´´) then

Boa Sorte

Buosi.


GOSTEI 0
Rsballoussier

Rsballoussier

01/03/2004

Tente assim:
...
if Pos(´violation´, E.Message) <> 0 then
MessageDlg(´Viõlação da Chave Primária!´, mtError, [mbOK], 0);
Action := daAbort;
...

Vá com tudo!


GOSTEI 0
POSTAR