Subject | Re: [IBO] Null parameter |
---|---|
Author | Helen Borrie |
Post date | 2008-07-04T05:01:12Z |
At 02:36 PM 4/07/2008, you wrote:
Helen
>HiNo.
>> 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.
> 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:Of course. A parameter is required. If the SP can take NULL in the parameter then it's valid to pass NULL in it. This is what you get by Clearing the parameter's assignment. I have no idea what you mean by "leaving it empty" in the case of an integer.
>>
>> 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 asThere ya go. ;-)
>passing null. Makes sense. That's all I needed to know :)
Helen