Subject Re: [firebird-support] CASE WHEN error
Author Helen Borrie
At 09:10 PM 25/11/2006, you wrote:
>Thanks for your help Helen.
>I am so sorry that I forgot to specify the kind of error.
>It gives "Dynamic SQL Error" as :
>
>"Invalid token.Dynamic SQL Error.
>SQL error code = -104.
>Token unknown - line 20, char 4.
>when."

You haven't said what version of Firebird you are using, nor what
dialect. The CASE syntax did not enter Firebird's SQL language until
v.1.5 and it won't work at all with a dialect 1 database.

>I correct the missing comma and quatos.
>h.hesap_sec_ tablo is constrained by NOT NULL.
>But I'm not sure if I understood true one part of your message, which was:
>
>"3) Run-time: you potentially have a run-time error through your use
>of subqueries in your CASE predications, too, if your subqueries
>happen to return multiple results (subquery expressions MUST return a
>singleton). However, if m.MUS_ID and pk.PER_ID are unique, there is
>no risk of a run-time error from these subqueries."
>
>MUS_ID is the Primary Key of Musteri_Karti table, and PER_ID is also
>the Primary Key of Personel_Kart table. If one field is a primary
>key of a table, that means this field is 'unique', am I right?

Yes, both are OK.


>I just try to write the code as you wrote, but it still gives same
>error that I mentioned above. I think I am missing same important
>part but I don't know where to concentrate on.

Well, if both your Firebird server version and your database dialect
support CASE, then copy your amended code into another reply and
let's look at it.

./heLen