Subject | Re: [IBO] NULL in TIB_Query.Params |
---|---|
Author | Helen Borrie |
Post date | 2001-01-09T10:21:38Z |
At 09:51 AM 09-01-01 +0100, you wrote:
But I'm sure Jason deals with 'is null' in the SQLWhere parser.
Here's how to do it with the parameters:
in some queries it can get scrambled. Always use ParamByName.
Try this out and come back with a RESULT. :))
btw, have you looked at the BLANKISNULL column attribute...I don't know
whether it helps in your current situation but it's worth knowing about,
e.g. to make sure an empty string gets written as NULL and not ''.
TShakers.
All for Open and Open for All
InterBase Developer Initiative ยท http://www.interbase2000.org
_______________________________________________________
>Hi all,This isn't valid SQL if :A is null, as has been pointed out.
>
>my question today is how to specify NULL in TIB_Query.Params? I tried
>calling Params[xx].Clear, Params.ClearBuffers(rsNone), assigning Null or
>Unassigned to Params[xx].Value but none of these works. Please consider the
>following test case:
>
>CREATE TABLE TEST (
> A INTEGER,
> B INTEGER
>);
>
>the test table contains the following data:
>
> A B
>============ ============
>
> <null> 1
> <null> 2
> 1 1
> 1 2
> 2 1
> 2 2
>
>I would like to use TIB_Query with a parameter. SQL.Text property contains
>statement 'SELECT * FROM TEST WHERE (A = :A)'.
But I'm sure Jason deals with 'is null' in the SQLWhere parser.
Here's how to do it with the parameters:
> with IB_Query1 doDon't use the Params[] array, you lose some essential stuff if you do and
> begin
> Close;
> if not Prepared then
> Prepare;
> Params[0].Clear;
> // Params.ClearBuffers(rsNone); <-- don't do this, we need the
> parameters and IBO looks after updating the values
in some queries it can get scrambled. Always use ParamByName.
> // Params[0].Value := Null; WRONGParamByName('A').Clear;
> // Params[0].Value := Unassigned; NOPE.You get EOF if the dataset is empty. You get BOF as well.
> Open;
> // here I always get Eof
Try this out and come back with a RESULT. :))
btw, have you looked at the BLANKISNULL column attribute...I don't know
whether it helps in your current situation but it's worth knowing about,
e.g. to make sure an empty string gets written as NULL and not ''.
TShakers.
All for Open and Open for All
InterBase Developer Initiative ยท http://www.interbase2000.org
_______________________________________________________