Subject | RE: [IBO] Need some help on unsigned integers (Cardinal) |
---|---|
Author | Jason Wharton |
Post date | 2018-03-06T16:10:53Z |
var
tmpS: string;
begin
tmpS := Trim( AsString );
if tmpS = '' then
Result := 0
else
try
Result := StrToUInt( tmpS );
except
Result := Trunc( StrToFloat( tmpS ));
end;
end;
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