Subject Re: [IBO] Null parameter
Author Robert martin
Hi
> First of all, you don't have to "reprepare etc" to pass a different parameter value. All you need to do is figure out how your application recognises NULL - and this
You misunderstand my original question. what I meant was that I could
changed the SQL the query was using between

SELECT *
FROM MyStoredproc(:ItemRef)

And

SELECT *
FROM MyStoredproc(NULL)


Which would require re preparing.

> entirely depends on how you're getting the values for Query.ParamByName('ItemRef').AsInteger. I'm sure you don't actually assign it the way you showed above. You must have variable or property, not something hard-coded....e.g.
>
> Query.ParamByName('ItemRef').AsInteger := SomeIntegerVar;
>
>
Yes I am doing that in code.

> Decide on some value for SomeIntegerVar that's not ever going to be used as an input value, say -99 if your input is always positive. Then, in your BeforeOpen, assign it like this:
>
> if SomeIntegerVar >= 0 then
> Query.ParamByName('ItemRef').AsInteger := SomeIntegerVar
> else
> Query.ParamByName('ItemRef').Clear;
>
>

I know when I want to set it as null just not how. I have tried leaving
it empty (not assigning) a value to the parameter in the past but to no
avail. I did not know that clearing the param would be the same as
passing null. Makes sense. That's all I needed to know :)


Thanks

Rob