Subject RE: [IBO] Query inserts record with all null values in v5.9 but not v5.5
Author Jason Wharton
All,
 
This issue was actually due to a bug in the DB.pas VCL unit of Delphi 5.

I implemented a work-around and a fix for future versions.
 
Thanks Greg for bringing this to my attention!
 
Regaards,
Jason Wharton


From: IBObjects@yahoogroups.com [mailto:IBObjects@yahoogroups.com]
Sent: Thursday, October 25, 2018 12:01 PM
To: IBObjects@yahoogroups.com
Subject: [IBO] Query inserts record with all null values in v5.9 but not v5.5

I recently upgraded to v5.9 and a function that inserts a record in to a table now inserts the record with every field having a null value.  If I roll back to v5.5 then the record gets inserted correctly.  Seems as there is some bug between version v5.5 and v5.9 that got introduced that prevents this code from running correctly but I can't tell what the difference between this code and any other insert statement in our system because this is the first time I have seen this issue while many other inserts in the system seem to be operating as they were before.  It executes without error, but just does not work as it should.  Here is the code in case it provides any insight as to the cause:

Procedure CreateDefaultOperation(const JOBNO:string;NewOperationUniid:Double;DateStartValue,DateEndValue:TDatetime);

var

    TempQueryCopyToOperation : TIBOQuery;

begin

     TempQueryCopyToOperation := TIBOQuery.create(nil);

     try

         TempQueryCopyToOperation.DatabaseName := 'JOBDATA2';

         TempQueryCopyToOperation.sql.ADD('INSERT INTO OPERATIONS');

         TempQueryCopyToOperation.sql.Add('(JOBNO,OPERNAME,DESCRIPT,NOTES,WORKCENTERNAME,');

         TempQueryCopyToOperation.sql.Add('STARTDATE,STATUS,SQUENCES,UNIID,ENDDATE,QTY) ');  //FMZZ


         TempQueryCopyToOperation.sql.Add('Values(:JOBNO,:OPERNAME,:DESCRIPT,:NOTES,:WORKCENTERNAME,');

         TempQueryCopyToOperation.sql.Add(':STARTDATE,:STATUS,:SQUENCES,:UNIID,:ENDDATE,:QTY)'); //FMZZ


         TempQueryCopyToOperation.ParamByName('JOBNO').AsString := JOBNO;

          if GetSetupString('DEFOPERATION') <> '' then

         TempQueryCopyToOperation.ParamByName('OPERNAME').AsString := GetSetupString('DEFOPERATION')

         else

         TempQueryCopyToOperation.ParamByName('OPERNAME').AsString := 'MainOperation';


         TempQueryCopyToOperation.ParamByName('DESCRIPT').AsString :=  'Default Operation';

         TempQueryCopyToOperation.ParamByName('NOTES').asmemo := 'Default Operation Notes';

         TempQueryCopyToOperation.ParamByName('WORKCENTERNAME').AsString := GetSetupString('DEFAULTWKC');

         TempQueryCopyToOperation.ParamByName('STATUS').AsString :='Scheduled';

         TempQueryCopyToOperation.ParamByName('SQUENCES').asInteger := TJobUtils.GetNextSquenceNo(Jobno);

         TempQueryCopyToOperation.ParamByName('UNIID').AsFloat := NewOperationUniid;

         TempQueryCopyToOperation.ParamByName('QTY').AsFloat := 1;

         TempQueryCopyToOperation.ParamByName('STARTDATE').asDatetime := DateStartValue;

         TempQueryCopyToOperation.ParamByName('ENDDATE').asDatetime := DateEndValue ;

         TempQueryCopyToOperation.ExecSQL;

     finally

         TempQueryCopyToOperation.close;

         TempQueryCopyToOperation.Free;

     end;

end;


It is pretty ugly yet simple code.  One last thing of note.  When using 5.9 if I step in to the execsql call, eventually there will be an access violation inside of the