Subject Re: [IBO] Recordcount Bug?
Author Helen Borrie
At 10:56 PM 27/08/2003 +0000, you wrote:
>Hi there,
>
>Calling Recordcount after opening the following query causes an error:
>
>SELECT 'FA' as
>TIPODOC,A.NUMERO,A.FECHA,B.CANTIDAD,B.UNITARIO,B.IMPORTE
>FROM FACTURAS A
>JOIN DETALLEFAC B ON (B.NUMERO=A.NUMERO)
>WHERE A.CLIENTE=:pClien AND A.FECHA BETWEEN :pDesde AND :pHasta
>AND A.CANCELADA='F'
>AND B.CVEART=:pArtic
>UNION
>SELECT 'PE' as
>TIPODOC,A.NUMERO,A.FECHA,B.CANTIDAD,B.UNITARIO,B.IMPORTE
>FROM PEDIDOS A
>JOIN DETALLEPED B ON (B.NUMERO=A.NUMERO)
>WHERE A.CLIENTE=:pClien AND A.FECHA BETWEEN :pDesde AND :pHasta
>AND A.CANCELADA='F'
>AND B.CVEART=:pArtic
>ORDER BY 2,1
>
>I open the query this way:
>
> with quDatos do
> try
> ParamByName('pClien').AsInteger:=quClientesNUMERO.AsInteger;
> ParamByName('pDesde').AsDateTime:=pfDesde.AsDateTime;
> ParamByName('pHasta').AsDateTime:=pfHasta.AsDateTime;
> ParamByName('pArtic').AsString:=pfClave.AsString;
> Open;
> if RecordCount=0 then // this line causes trouble
>
>
>Error message is:
>SQL error code = -104
>invalid command
>count of column list and variable list do not match

This exception occurs on an insert!! So - to work out what's going on here
one would need to know a lot more about your setup, i.e. what caused your
dataset to go into insert mode.


>Error is in TIBOInternal dataset.
>
>Please note that if instead of Recordcount I use the IsEmpty
>property, everything's OK.

To keep it simple, finding out why you got that weird exception doesn't
really solve an immediate problem. RecordCount is not a sensible thing to
use here. It's a property that is a legacy from paradox and it's pretty
meaningless in IB/Fb. IsEmpty is the right way to test for the presence of
rows in a dataset, as it always was, even with the BDE.

Helen