Subject | Re: [IBO] RecordCount and Union |
---|---|
Author | Svein Erling Tysvaer |
Post date | 2006-12-06T11:26:38Z |
What would be a correct fix, Michael?
I mean
select count(*)
from Ekspedienter
union
select count(*)
from EkspedienterTilSalg
would return two records (not ideal when asking for one value, requires
more manual work behind the scenes to merge the results and may still
yield an incorrect result), whereas
select count(*)
from
(select nr, navn
from Ekspedienter
union
select nr, navn
from EkspedienterTilSalg)
requires Firebird 2.0 (or possibly some IB version, I don't know recent
IB versions).
Unfortunately, I don't know whether more recent IBO versions handles
things differently or not (your actual question). I agree with you that
the current behaviour isn't good, but wonder which fix to suggest to
Jason (though for all I know, he may already have a solution).
Set
Michael Vilhelmsen wrote:
I mean
select count(*)
from Ekspedienter
union
select count(*)
from EkspedienterTilSalg
would return two records (not ideal when asking for one value, requires
more manual work behind the scenes to merge the results and may still
yield an incorrect result), whereas
select count(*)
from
(select nr, navn
from Ekspedienter
union
select nr, navn
from EkspedienterTilSalg)
requires Firebird 2.0 (or possibly some IB version, I don't know recent
IB versions).
Unfortunately, I don't know whether more recent IBO versions handles
things differently or not (your actual question). I agree with you that
the current behaviour isn't good, but wonder which fix to suggest to
Jason (though for all I know, he may already have a solution).
Set
Michael Vilhelmsen wrote:
> Hi
>
> I use D5 and IBO version 4.3.A
>
> I discovered yesterday, that if I had an SQL statement like this:
>
> select
> nr,
> Navn
> from ekspedienter
> where
> Ekspedienter.afdeling_ID=:PAfdeling_ID and ekspedienter.nr=99999
>
> Union
>
> Select
> nr,
> navn
> from EkspedienterTilSalg Where
> Afdeling_ID=:PAfdeling_ID and
> UAfd_Navn=:PUAfd_Navn
>
> And later did a MyQuery.RecordCount it was turned into:
>
> select
> Count(*)
> from ekspedienter
> where
> Ekspedienter.afdeling_ID=:PAfdeling_ID and ekspedienter.nr=99999
>
> Union
>
> Select
> nr,
> navn
> from EkspedienterTilSalg Where
> Afdeling_ID=:PAfdeling_ID and
> UAfd_Navn=:PUAfd_Navn
>
> Which gave me this error:
>
> ISC ERROR CODE : 335544569
> Dynamic SQL Error SQL error code = -104 Invalid command count of
> column list and variable list do not match
>
> It this fixed in a newer version ?
>
> Michael