Subject Error when trying recordcount > 0
Author

Greetings

Since yesterday i've got a "weird" error

i have a cursor and after i open it, i try to check record count and i get the following error

"attempt to fetch past the last record in a record stream."

i've managed to overcome by validating when eof or QProducoesActivas.CursorRowNum > 0


this has appened since Firebird changed from 2.1 on Windows to 2.5 on Linux, what can it be?



cursor declaration and validation


 QProducoesActivas := TIB_Cursor.Create(nil);
   QProducoesActivas.IB_Connection := DMGeral.BaseDados;
   QProducoesActivas.IB_Transaction := DMGeral.TransacaoLeitura;
   QProducoesActivas.close;

 

   QProducoesActivas.Sql.Clear;
   QproducoesActivas.SQL.Add('SELECT  (select c.quant_feita ');
   QproducoesActivas.SQL.Add('FROM cpa_necessidades_Producao c ');
   QproducoesActivas.SQL.Add('WHERE c.serie=h.serie   AND h.ano_plano=c.ano_plano AND h.cod_Plano=c.cod_plano ');
   QproducoesActivas.SQL.Add('AND h.codigo_arm=c.codigo_arm AND h.Referencia=c.Referencia AND h.linha=c.n_linha AND h.cod_operacao=c.cod_operacao ');
   QproducoesActivas.SQL.Add('AND h.ordemprod = c.ordemprod  ');
   QproducoesActivas.SQL.Add(')  AS QTDProd , sum(h.tempo_util) AS TotHoras, floor( sum(h.quantidade)/sum(h.tempo_util)) AS Cadencia_Real');
   QProducoesActivas.SQL.Add('FROM cpa_hist_operacoes h');
   QProducoesActivas.Sql.Add('WHERE h.serie=:serie AND h.ano_plano=:ano_plano AND h.cod_Plano=:cod_plano AND h.num_viatura=:num_viatura ');
   QProducoesActivas.Sql.Add('AND h.codigo_arm=:codigo_arm AND h.Referencia=:Referencia AND h.linha=:n_linha AND h.cod_operacao=:cod_operacao');
   QProducoesActivas.Sql.Add('AND h.ordemprod = :ordemprod ');
   QProducoesActivas.SQL.Add('GROUP BY h.serie, h.ano_plano, h.num_viatura, h.cod_plano, h.codigo_arm, h.referencia, h.cod_operacao, h.ordemprod, h.linha ');
   QProducoesActivas.Open();

...


 QProducoesActivas.ParamByName('serie').AsString := MemLinhasPlaneamento.FieldByName('serie').AsString;
         QProducoesActivas.ParamByName('ano_plano').AsString := MemLinhasPlaneamento.FieldByName('ano_plano').AsString;
         QProducoesActivas.ParamByName('cod_Plano').AsString := MemLinhasPlaneamento.FieldByName('cod_Plano').AsString;
         QProducoesActivas.ParamByName('codigo_arm').AsString := MemLinhasPlaneamento.FieldByName('codigo_arm').AsString;
         QProducoesActivas.ParamByName('Referencia').AsString := MemLinhasPlaneamento.FieldByName('Referencia').AsString;
         QProducoesActivas.ParamByName('n_linha').AsString := MemLinhasPlaneamento.FieldByName('n_linha').AsString;
         QProducoesActivas.ParamByName('cod_operacao').AsString := MemLinhasPlaneamento.FieldByName('cod_operacao').AsString;
         QProducoesActivas.ParamByName('ordemprod').AsString := MemLinhasPlaneamento.FieldByName('ordemprod').AsString;
         QProducoesActivas.ParamByName('num_viatura').AsString := MemLinhasPlaneamento.FieldByName('maquina').AsString;
  
         QProducoesActivas.RefreshKeys();
         

         if( QProducoesActivas.recordcount > 0 ) ....