Subject Re: [firebird-support] Error message from an invalid SQL Query
Author Svein Erling Tysvaer
Michael Vilhelmsen wrote:
> Hi
>
> I just had a strange problem with a query, which I got solved with
> some help from Martijn Tonies.
>
> I got an error message in my appl. and couldn't quite figure it out.
> Whatever I googled said something about stored procedures ....
>
> The SQL that was about to be executed was:
>
> 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
>
> Its not something I generated, but rather IBO doing it internally
> (When doing a MyQuery.RecordCount).
>
> The error that comes up is this:
>
> ISC ERROR CODE : 335544569
> Dynamic SQL Error SQL error code = -104 Invalid command count of
> column list and variable list do not match
>
> In my point of view this error message is a bit wierd.
>
> I ran this query on a FB 1.5.3 and Fb 2.0
>
> Regards
> Michael

Excepting that I would want a comma (Invalid command, count of
column list and variable list do not match), I find this error message
descriptive enough. Let's look at the SQL:

>select
> Count(*)
>from ...

This says that the query should return one column of type integer (or
similar)

then you do

> Union
>
> Select
> nr,
> navn
> from ...

this is two columns that have to be put into the one integer column
above. That's impossible, hence 'count of column list and variable list
do not match'. Mind you, I certainly wouldn't object if it was changed
to something like 'incorrect number of columns specified' or similar,
but I'm generally not all too unhappy with this error message.

Though, of course IBO ought to be improved in cases like this (I've
never tried counting a UNION, and kind of doubt that it is feasible, so
the improvement could be to simply refuse to do the count).

Set