luizdspinola Posted June 19, 2021 Posted June 19, 2021 Hello everybody. I'm having a hard time developing a database insert. I have a custom auto inc field that is managed by the application, I use try/except combined with EDatabaseError to handle error if duplicate insertion attempt happens but execution interrupts without going through except See the code: procedure insere_dados(NUMERO: INTEGER): begin try TABELA.FieldByName('INC').AsString:= NUMERO; //CHAVE PRIMARIA TABELA.FieldByName('DATA').AsString:= DateToStr(now); TABELA.FieldByName('USUARIO').AsString:= ID_Usuario; TABELA.Post; TABELA.ApplyUpdates; //ATUALIZA BASE DE DADOS MessageDlg('Informações inseridas com sucesso.', mtInformation, [mbOK]); except on eDataBaseError do //or EFDDBEngineException begin TABELA.Cancel; TABELA.CancelUpdates; //CANCELA ATUALIZACAO NUMERO:= NUMERO+1; //INCREMENTA NUMERO insere(NUMERO); //CHAMA A PROC NOVAMENTE end; end;
Sherzod Posted June 19, 2021 Posted June 19, 2021 Hello, Sorry, your case is not very clear to me. And please specify, which edition and build of UniGUI are you using?
Tokay Posted June 20, 2021 Posted June 20, 2021 19 hours ago, luizdspinola said: on eDataBaseError do //or EFDDBEngineException May be common on Exception can help you.
Recommended Posts