Subject RE: [IBO] Null parameter
Author Jerry Sands
I believe Helen answered that, to get the stored procedure called with the
"ItemRef" value being a null, you use "Query.ParamByName('ItemRef').Clear"



Jerry Sands



From: IBObjects@yahoogroups.com [mailto:IBObjects@yahoogroups.com] On Behalf
Of Robert martin
Sent: Thursday, July 03, 2008 11:36 PM
To: IBObjects@yahoogroups.com
Subject: Re: [IBO] Null parameter




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





[Non-text portions of this message have been removed]