Subject RE: [IBO] Need some help on unsigned integers (Cardinal)
Author Jason Wharton
Dany,
 
Thanks for pointing this out.
 
If you patch this method as indicated, does that make it work?

procedure TIB_Column.SetAsLongWord( const NewValue: LongWord );
begin
  // AsString := IntToStr( NewValue );
  AsString := UIntToStr( NewValue );
end;
 
I was thinking IntToStr( DWORD ) would have used the int64 overload instead of the integer overload.
 
Jason Wharton
 


From: IBObjects@yahoogroups.com [mailto:IBObjects@yahoogroups.com]
Sent: Tuesday, March 06, 2018 8:26 AM
To: IBObjects@yahoogroups.com
Subject: [IBO] Need some help on unsigned integers (Cardinal)

 

Maybe i have not had the need to store Delphi "Cardinal" before.

I have a stored procedure that takes an INTEGER argument. (I cannot find any UINTEGER type in FB).


When i use this statement to set the value:


MyCol.AsLongWord = aCardinalParamValue;


I get an exception when the value exceeds the signed positive interval, for example: '2533700138' is not a valid integer value.


This is because the value gets converted to a 64-bit string in "SetAsLongWord" and then back to a signed 32.bit integer in TIB_ColumnInteger.SetAsString. That the TIB_ColumnInteger variant of SetAsString is called indicates to me that i have done something wrong. Maybe i should define the column differently? Or maybe simply cast all my Cardinals to signed 32-bit integers when storing and back when retrieving?


To sum it up: Does anyone have a good way of storing and retrieving unsigned 32-bit integers from FB 2.5-3.0 using IBO? I'd much grateful.


Regards,


/Dany