Thanks J
Von: firebird-support@yahoogroups.com [mailto:firebird-support@yahoogroups.com] Im Auftrag von Tim Ward Gesendet: Dienstag, 14. Januar 2014 10:37 An: firebird-support@yahoogroups.com Betreff: Re: [firebird-support] iif and coalesce There is an answer to this sort of thing because I had some code that used to do something like it. However the resulting performance was pretty awful. I ended up generating different SQL for the two cases and running the result with EXECUTE STATEMENT. On 14/01/2014 09:33, checkmail wrote: Hello, I would like to use dynamic conditions without an statement like: Condition customer can be 0 (all costomers) or inherits a number of a customer This doesn't work: select * from table where iif(:input_customer_id <> 0;'customer_id = ' || :input_customer_id,'') I can set the input_customer_id to null when its value = 0, perhaps can I realize this with coalesce? Where customer_id = coalesce(:input_customer_id;'.') But I can't set = and > 0 at the same time or = coalesce(..) and not null. How can I finish my plan? Also I don't like to set some if-statements. if input = 0 etc., there many inputs. Thank you. Best regards. Olaf -- Tim Ward