Forum > Database
Lazarus SQLQuery BCDField problem with Firebird
(1/1)
dogriz:
When I try to save value 999999999 into Firebird database field - decimal(15,2) from Lazarus application, value -844674408,37 is saved instead.
Used components are IBConnection, SQLQuery and DBEdit.
I made a simple example using employee database - just added one test field:
--- Code: ---alter table EMPLOYEE add TEST_FIELD decimal(15,2)
--- End code ---
Sample application is attached.
Does anyone know why is this happening? Saving the same number (999999999) using isql or FlameRobin works as expected.
BTW, Lazarus 1.8.2/FPC 3.0.4 on Windows 10 64bit + Firebird 3.0.3 64bit.
valdir.marcos:
Try with Numeric or BigInt:
https://firebirdsql.org/file/documentation/reference_manuals/fblangref25-en/html/fblangref25-datatypes-fixedtypes.html
https://firebirdsql.org/refdocs/langrefupd25-bigint.html
dogriz:
I just tested it on Linux + Lazarus/FPC trunk and it works OK.
Just don't know why it misbehaves on Win + 1.8.2/3.0.4
Update: I crosscompiled from Linux + Lazarus/FPC trunk to Windows and when I run the app on Win, it doesn't work OK...
valdir.marcos:
I am using Lazarus 1.8.2, FPC 3.0.4, Firebird 2.5 on Windows 7 Pro 64 bits.
Results are identical on both Lazarus and FlameRobin.
See the attached image.
--- Code: SQL [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---CREATE TABLE TestBigNumbers( ID INTEGER NOT NULL PRIMARY KEY, Field_Decimal DECIMAL(15,2), Field_Numeric NUMERIC(15,2), Field_BigInt BIGINT );Commit; INSERT INTO TestBigNumbers(ID, Field_Decimal, Field_Numeric, Field_BigInt) VALUES (1, 999999999, 999999999, 999999999);Commit; SELECT * FROM TestBigNumbers;
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.Button1Click(Sender: TObject);begin SQLQuery1.SQL.Clear; SQLQuery1.SQL.Text := 'Insert Into TestBigNumbers(ID, Field_Decimal, Field_Numeric, Field_BigInt) ' + 'Values (2, 999999999, 999999999, 999999999);'; SQLQuery1.ExecSQL; SQLTransaction1.Commit; ShowMessage('OK');end;
valdir.marcos:
I have changed your project to work with my clean database and it worked correctly.
I even changed from Firebird 2.5.8 to 3.0.3 and no error.
See image.
Is your fbclient.dll on version 3.0.3?
Instead of using Employee.fdb, create a new database.
Maybe, start another sample project from zero...
Navigation
[0] Message Index