Subject Re: Bug with NULL parameters, sample
Author Jason Wharton
Karsten,

Here is the fix which you can easily apply:

procedure TIB_Column.SetIsNull( const NewValue: boolean );
begin
if ( NewValue <> IsNull ) or
(( NewValue and not IsNullable ) and ( Row.RowType = rtParam )) then
begin
SysBeforeModify;
SysSetIsNull( NewValue );
SysAfterModify;
end;
end;

I just had to make it so that it would toggle the IsNullable status when
setting a param based on a non-nullable column to null.

Thanks,
Jason Wharton
CPS - Mesa AZ
http://www.ibobjects.com


----- Original Message -----
From: "Karsten Strobel" <strobel@...>
To: <jwharton@...>
Sent: Sunday, April 29, 2001 6:20 AM
Subject: Bug with NULL parameters, sample


> Hi Jason,
>
> here's a simplified sample for the NULL parameter bug I was talking
> about. The bug can be reproduced very easy.
>
> Steps to reproduce:
>
> 1.
> Create the Database in C:\Temp\Richard.gdb
>
> 2.
> Create a table and insert one record:
>
> CREATE TABLE TEST (T1 INTEGER NOT NULL PRIMARY KEY, T2 INTEGER NOT
> NULL);
> INSERT INTO TEST vALUES (1, 1);
>
> 3.
> Open an Run Null_Param_Problem.dpr (with Delphi-5)
>
>
> I looked into it and I think that it might have to do with the
> initialization state of params in TIB_Row respectevely the XSQLDA
> structure.
>
> This is from MainUnit.pas:
>
> with MyQuery do
> begin
> SQL.Text := 'UPDATE Test Set T2=:T2 where T1=1';
> if cbWorkaround.Checked then
> ParamByName('T2').AsInteger := 42;
> ParamByName('T2').Clear;
> ExecSQL;
> end;
>
> Without the workaroung line, the :T2 parameter is passed to the database
> as "0". With the workaroung line, :T2 is correctly cleared and a NULL is
> passed to Interbase.
>
> I suspect that it has something to do with the fact that a newly created
> TIB_Row (for the param) has the states ".IsNull=true" but
> ".IsNullable=false".
>
> I hope this helps you to locate this bug.
>
> Karsten
>
>