Mark Rotteveel wrote:

> On Wed, 19 Aug 2015 11:22:35 +0200, Paul Vinkenoog <p...@vinkenoog.nl>
> wrote:
> > Hi all,
> > 
> >> > I think this is mistake, isn't it? Abount "SOME_COL = ? OR ? IS NULL
> >> > Predication"
> >> >
> >> > ---
> >> > • If “param1” is not NULL, the language interface is required to
> >> > assign the correct value for the first parameter, set the
> >> > XSQLVAR.sqlind to NOT NULL and leave XSQLVAR.sqldata NULL.
> >> > ---
> >> >
> >> > fix this
> >> >
> >> > ---
> >> > • If “param1” is not NULL, the language interface is required to
> >> > assign the correct value for the first parameter, set the
> >> > XSQLVAR.sqlind to NOT NULL.
> >> > ---
> >>
> >> As far as I can tell the existing text is intentional and correct. It
> >> tries to convey that the value of XSQLVAR.sqldata is irrelevant for
> >> parameters in ? IS NULL (and therefor is best left NULL).
> > 
> > Tsutomu is right. param1 is the parameter with a 'normal' SQL data type
> > (i.e. not SQL_NULL). So if it is not NULL, XSQLVAR.sqldata should point
> > to the value and XSQLVAR.sqlind should be set to 0 (indicating NOT
> NULL).
> > 
> > Only in the second parameter (the one in "? IS NULL", of SQL_NULL type)
> > should XSQLVAR.sqldata always be null (null pointer).
> 
> The way I read it, "set the XSQLVAR.sqlind to NOT NULL and leave
> XSQLVAR.sqldata NULL." refers to the "? IS NULL" parameter, not the first
> parameter ("SOME_COL = ?").

If you read it in context (see below), you see that param1 refers to the
first positional parameter and param2 (not mentioned in Tsutomu's post)
to the second.

>From the 2.5.4 Release Notes:

"The implementation works like this. To resolve the first problem, the
request must supply two parameters (for our Delphi example):

  WHERE col1 = :param1 OR :param2 IS NULL

• If “param1” is not NULL, the language interface is required to assign
  the correct value for the first parameter, set the XSQLVAR.sqlind to
  NOT NULL and leave XSQLVAR.sqldata NULL.

• If “param2” is NULL, the language interface is required to set the
  XSQLVAR.sqlind of both parameters to NULL and leave the
  XSQLVAR.sqldata NULL."

Even apart from the incorrect "and leave XSQLVAR.sqldata NULL", this
text is a bit confusing and incomplete. It should be something like this:

"First of all, the language interface should ensure that :param1 and
:param2 have the same value (or nullness), as they reflect the same user
level variable. Then,

- If they are not NULL, XSQLVAR.sqldata of the first param must point
to the value and XSQLVAR.sqldata of the second param must be null (null
pointer, not SQL NULL).

- If they are NULL, XSQLVAR.sqldata of both params must be null (null
pointer, not SQL NULL).

In all cases, XSQLVAR.sqlind of both params must reflect the nullness
of the parameter (i.e. point to a -1 value for NULL, or 0 for NOT NULL)."

To be honest, I didn't quote the entire text from the RelNotes. With the
paragraphs that follow, you can figure out how everything should be set
up, but it's a bit of a puzzle.

You could also sum up the instructions like this:
"Set up both XSQLVAR's like you would normally do and make them equal,
but set XSQLVAR.sqldata of the SQL_NULL param to null at all times."


Cheers,
Paul

------------------------------------------------------------------------------
_______________________________________________
Firebird-docs mailing list
Firebird-docs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/firebird-docs

Reply via email to