Error adding BD information

Asked

Viewed 160 times

4

When testing in the application where I migrated the BD from Firebird to Postgresql the following error occurs when trying to save an item in the database:

inserir a descrição da imagem aqui

Reviewing the code I could see that the error actually occurs at this point in the code:

    dmCadMib.Consulta_Cliente(Cliente); // Nessa Linha pula para a procedure Consulta_Cliente
    dmCadMib.ConsClienteNoGrupo;
    dmCadMib.localizaCliente(StrToInt(Cliente));
Procedure Consulta_Cliente:

procedure TdmCadMIB.Consulta_Cliente(Codigo: string);

begin 
   cdsEmpresa.Close;
   sdsEmpresa.CommandText := 'select * from Empresa where Codigo =' + Codigo;
   cdsEmpresa.Open;
end;
  • In which of the two Inserts gives the error? And you can debug and put the string formed the way it goes to BD?

  • I edited the @Sorack question with the correct point where the error occurs

  • Okay, but put the string formed by this, ie, what will effectively BD. It is syntax error, so it will be extremely simple to find the error

  • Beware of cdsEmpresaNOME.AsString, depending on what is in this variable can give syntax problem in SQL or worse. Instead, use parameters

2 answers

6


The only thing that could be wrong is that its variable Cliente empty or void. But there has to be seen in the business rule where it should be filled.

syntax error at the end of the input

It’s an error returned by the bank, your query is being sent as:

select * from Empresa where Codigo =;

4

The Solution I found was to convert the variable codigo for integer which was the format that was in the bank:

the solution was just that: procedure TdmCadMIB.Consulta_Cliente(Codigo: string); I switched to procedure TdmCadMIB.Consulta_Cliente(Codigo: Integer);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.