Error set Parameters value in Query

Asked

Viewed 100 times

1

I got a problem with that SQL in the Lazarus with Zeos and Firebird every time I perform the procedure of error. I’ve Already Added Parameters in the Component TZQuery.

  • Error message:

    [Notificação Exceções Depurador]
    Projeto Autosad elevou classe exceção 'EZSQLException' com a mensagem:
    SQL Error:  Dynamic SQL Error SQL error code =
    -303 arithmetic exception,numeric overflow, or string truncation string right truncation
    Error Code: -303. <br> Incompatible column/host variable data type The SQL:
    Select T1.DATA_AUDIENCIA, T1.HORA_AUDIENCIA, T2.NUMERO_PROCESSO, T1.NUMERO_E_VARA,
    T1.ORGAO, T1.COMARCA, T1.ADVOGADO_DILIGENTE, T3.NOME_CLIENTE, T2.PARTE_CONTRARIA
    from AUDIENCIAS T1, PROCESSOS T2, CLIENTES T3
    where T1.NUMERO_PROCESSO = T2.NUMERO_PROCESSO and T2.COD_CLIENTE = T3.COD_CLIENTE and
    T1.DATA_AUDIENCIA >= ? and T1.HORA_AUDIENCIA >= ?
    order by T1.DATA_AUDIENCIA, T1.HORA_AUDIENCIA; 
    
    No arquivo:
    'C:\Lazarus\components\Zeosdbo\src\dbc\ZDbcInterbase6Utils.pas' na linha 910
    
  • Code:

    procedure TfrmEntradaSistema.AlimentaQryAudienciasInicial;
    var vSql:String;
    begin
      // Prepara e executa QUERY com as PROXIMAS AUDIENCIAS para a Tela Inicial
      vSql := 'Select '+
          '  T1.DATA_AUDIENCIA, '+
          '  T1.HORA_AUDIENCIA, '+
          '  T2.NUMERO_PROCESSO, '+
          '  T1.NUMERO_E_VARA, '+
          '  T1.ORGAO, '+
          '  T1.COMARCA, '+
          '  T1.ADVOGADO_DILIGENTE, '+
          '  T3.NOME_CLIENTE, '+
          '  T2.PARTE_CONTRARIA '+
          'from '+
          '  AUDIENCIAS T1, '+
          '  PROCESSOS T2, '+
          '  CLIENTES T3 '+
          'where '+
          '  T1.NUMERO_PROCESSO = T2.NUMERO_PROCESSO and '+
          '  T2.COD_CLIENTE     =  T3.COD_CLIENTE    and '+
          '  T1.DATA_AUDIENCIA >= :AudData and '+
          '  T1.HORA_AUDIENCIA >= :AudHora '+
          'order by T1.DATA_AUDIENCIA, T1.HORA_AUDIENCIA';
      DataModuleGeral2.qryAudienciasInicial.Close;
      DataModuleGeral2.qryAudienciasInicial.SQL.Clear;
      DataModuleGeral2.qryAudienciasInicial.SQL.Add(vSql);
      // Parâmetro
      DataModuleGeral2.qryAudienciasInicial.Params.ParamValues['AudData'] := QuotedStr(StringReplace(DateToStr(DataModuleGeral.tbParametrosDATA_SISTEMA.AsDateTime),'/','.',[rfReplaceAll]));
      DataModuleGeral2.qryAudienciasInicial.Params.ParamValues['AudHora'] := QuotedStr(TimeToStr(Time));
      DataModuleGeral2.qryAudienciasInicial.ExecSQL;
      DataModuleGeral2.qryAudienciasInicial.Active := True;
      DataModuleGeral2.qryAudienciasInicial.First;
    end;
    

How can I fix this?

  • This error probably has to be related to date conversion.

  • and how it solves?

1 answer

1

// Parâmetro
DataModuleGeral2.qryAudienciasInicial.Params.ParamByName['AudData'].AsString :=

I didn’t test your code. But that was the first thing that caught my attention.

  • I don’t understand your answer?

Browser other questions tagged

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