Error adding information in DB

4

When testing the application where I migrated the Firebird DB to PostgreSQL, the following error occurs when trying to save an item in the database:

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;
    
asked by anonymous 21.11.2016 / 20:58

2 answers

6

The only thing that may be wrong is that your Cliente variable is empty or null. But there you have to look at the business rule where it should be filled.

  

syntax error at the end of the input

It is an error returned by the bank, its query is being sent as:

select * from Empresa where Codigo =;
    
23.11.2016 / 16:37
4

The solution I found was to convert the variable codigo to integer which was the format that was in the database:

The solution was just this: procedure TdmCadMIB.Consulta_Cliente(Codigo: string); changed to procedure TdmCadMIB.Consulta_Cliente(Codigo: Integer);

    
23.11.2016 / 16:48