Subject BigInt in Delphi 5
Author

Jason, in October you helped me worked through some of the issues I was encountering migrating away from BDE to IBO.  One of the things we discussed was dealing with the fact that calculated integer fields default to the BigInt type, which Delphi 5 cannot handle.  I had made my own custom patch to the GetDataTypeAndSize function in IBODataset.pas, which prevented ftLargeInt from every being chosen as a datatype.  In talking with you, you suggested different implementation of the fix which was to instead modify TIBOLargeintField.GetAsVariant to handle D5 differently than later versions.  While this seemed to work to fix cases where we were using AsInteger to get the value out, there are other patterns that this is not working for.  We find ourselves close to a release but we keep finding bits of code failing where the BigInt issue is the cause.  Checking for null does not work properly.  Getting the value in a DxGrid (3rd party) OnDrawCell is not working and it seems to be because they are providing the values of the row being drawn as variant and again it shows as null when it should be a non-null integer.  


I would like to propose my original patch to be made officially part of the IBO codebase.  It seems to work for me in all the scenarios I have seen without altering the original SQL that worked with BDE.  Delphi 5 can never handle 64bit integers in variants, so my patch says that no matter what the largest integer datatype possible is ftInteger.  I am going to patch all of our machines to have IBO modified in this way, and my hope is that you will accept this change in to the official IBO codebase so that we don't accidentally regress this fix in the future after an update to IBO is applied should we forget to make our custom patch to the IBO codebase.

The original code in GetDataTypeAndSize was written as (just the relevant snippet):

          case ACol.SQLType of

            SQL_SHORT,

            SQL_SHORT_: NewDataType := ftSmallint;

            SQL_LONG,

            SQL_LONG_: NewDataType := ftInteger;

            else

              NewDataType := ftLargeInt;

          end;

I propose that this be changed to:

          case ACol.SQLType of

            SQL_SHORT,

            SQL_SHORT_: NewDataType := ftSmallint;

{$IFDEF IBO_VCL60_OR_GREATER}

            SQL_LONG,

            SQL_LONG_: NewDataType := ftInteger;

            else

              NewDataType := ftLargeInt;

{$ELSE}

            else

              NewDataType := ftInteger;

{$ENDIF}

          end;

This is what I originally used that works, except now I added in the compiler directive which should make it work all versions of Delphi so that you can include this in the main IBO codebase.

Thanks,

Greg Cobb

Software Developer at DBA Software, Inc.