Subject | Re: [firebird-support] string comparisons |
---|---|
Author | Ernesto Benestante |
Post date | 2004-09-23T15:13:11Z |
> >SELECT C FROM T WHERE (X = :A) AND (((Y IS NULL) AND (:B = '')) OR (Y =:B))
> >was
> >What a kludge! But if it works... he, of course it didn't. Whenever :B
> >not empty the query failed with an error: "arithmetic exception, numericExcuse me, but I didn't understand your answer. By rewriting the query, I
> >overflow, or string truncation."
>
> Empty string is not the same as NULL. And a predicate that is passed as
>
> where aValue = NULL
>
> is not syntactically valid.
>
was trying to avoid exactly that construct. But... perhaps you are referring
to the case where Y is NULL but :B is not empty, so in that case I will
again be comparing :B to NULL, when the first part of the or subexpression
fails. Lets see... I rewrote the query as:
SELECT C FROM T WHERE (X = :A) AND (((Y IS NULL) AND (:B = '')) OR ((NOT Y
IS NULL) AND (Y = :B)))
But, this one also fires the "arithmetic exception, numeric overflow, or
string truncation" error, in the same cases as the previous one (when :B is
not empty).
> So, assuming that you want to treat nulls in Y as though they were emptyMmm, I guess that's a new function in FB 1.5 (I'm still using FB 1.0.3). I
> strings, alter your query to this:
>
> SELECT C FROM T
> WHERE X = :A
> AND COALESCE(Y, '') = :B
>
> ./heLen
>
get a "Funcion unknown COALESCE" error when trying to execute the query.
EB.