Subject RE: [IBO] RecordCount and Union
Author Jason Wharton
Yes, it is fixed to tell you that you "Can't do that" (not in those exact
words, but more or less).

Jason

> -----Original Message-----
> From: IBObjects@yahoogroups.com [mailto:IBObjects@yahoogroups.com]On
> Behalf Of Michael Vilhelmsen
> Sent: Wednesday, December 06, 2006 7:53 AM
> To: IBObjects@yahoogroups.com
> Subject: Re: [IBO] RecordCount and Union
>
>
> --- In IBObjects@yahoogroups.com, Svein Erling Tysvaer
> <svein.erling.tysvaer@...> wrote:
> >
> > What would be a correct fix, Michael?
>
> What about trowing up an error, saying "Can't do that !"
>
> 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:
> > > 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