Subject | Re: [IBO] Null parameter |
---|---|
Author | Robert martin |
Post date | 2008-07-04T04:36:20Z |
Hi
changed the SQL the query was using between
SELECT *
FROM MyStoredproc(:ItemRef)
And
SELECT *
FROM MyStoredproc(NULL)
Which would require re preparing.
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
> 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 thisYou 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.Yes I am doing that in code.
>
> Query.ParamByName('ItemRef').AsInteger := SomeIntegerVar;
>
>
> 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:I know when I want to set it as null just not how. I have tried leaving
>
> if SomeIntegerVar >= 0 then
> Query.ParamByName('ItemRef').AsInteger := SomeIntegerVar
> else
> Query.ParamByName('ItemRef').Clear;
>
>
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