Re: Parametrized query fails
Posted in 1996
Alexander Ponomarenko <shura@bitcom.msk.ru> wrote: :>Alexander Ponomarenko <shura@bitcom.msk.ru> wrote: :>>Hi all! :>> :>>I use Informix OnLine 6.0WF1 with Delphi and have serious problem with :This is mistake, version is UD2. :>>parametrized queries: :>>When I execute something like: :.. SKIPPING ... :> :>You have the answer right there: :>>altough there are lots of records where address is NULL. I test that with :> :>You must use the IS clause when checking for NULL values. :> :>select * from customers where address is null :> :>Catalin :> :Thank you! :Possible my bad English was the cause of your misunderstanding of my question. I :asked about query with parameters, i.e. when I don't know in advance contents of :field. We have in our program form like this: :.. :Address: _____ :Phone: _____ :.. :User can type something in fields but can leave they blank. Of course, we can :analyze address and if it is null substitute one query by another, but how this is :inconvenient! We have tens of field, so for any possible combination we should :have NOFIELDS^2 queries. Horrible! Is there some other way to do this? :Thanks in advance! You may find it horrible (and I even tend to agree), but it's still *standard* SQL. If your other database server(s) doesn't require you to use the is null syntax they are wrong, not Informix - unfortunately. Now it shouldn't be to hard in Delphi to write a rutine that generates your sql-command with the right syntax. This could than be prepared and executed. You should definitely not need to substitute one query by another. That would be next to impossible with only a few fields. It must be generated on the fly every time. Another thing: This looks like you are generating a query by example form. You will probably find it better to exclude the fields where the user has typed nothing from your query altogether like in the Informix 4GL construct statement. That's more intuitive for users. Than if they actually want to search for null-values they have to type an = sign alone in the corresponding field (meaning equal nothing). Nils.Myklebust@ccmail.telemax.no NM Data AS, P.O.Box 9090 Gronland, N-0133 Oslo, Norway My opinions are those of my company