Recent

Author Topic: Lazarus SQLQuery BCDField problem with Firebird  (Read 4647 times)

dogriz

  • Full Member
  • ***
  • Posts: 126
Lazarus SQLQuery BCDField problem with Firebird
« on: April 25, 2018, 07:14:52 pm »
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: [Select]
alter table EMPLOYEE add TEST_FIELD decimal(15,2)
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.
FPC 3.2.2
Lazarus 2.2.4
Debian x86_64, arm


dogriz

  • Full Member
  • ***
  • Posts: 126
Re: Lazarus SQLQuery BCDField problem with Firebird
« Reply #2 on: April 25, 2018, 08:33:26 pm »
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...
« Last Edit: April 25, 2018, 09:04:55 pm by dogriz »
FPC 3.2.2
Lazarus 2.2.4
Debian x86_64, arm

valdir.marcos

  • Hero Member
  • *****
  • Posts: 1106
Re: Lazarus SQLQuery BCDField problem with Firebird
« Reply #3 on: April 26, 2018, 01:29:55 am »
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  [Select][+][-]
  1. CREATE TABLE TestBigNumbers(
  2.   ID            INTEGER NOT NULL PRIMARY KEY,
  3.   Field_Decimal DECIMAL(15,2),
  4.   Field_Numeric NUMERIC(15,2),
  5.   Field_BigInt  BIGINT
  6.   );
  7. Commit;
  8.  
  9. INSERT INTO TestBigNumbers(ID, Field_Decimal, Field_Numeric, Field_BigInt) VALUES (1, 999999999, 999999999, 999999999);
  10. Commit;
  11.  
  12. SELECT * FROM TestBigNumbers;

Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. begin
  3.   SQLQuery1.SQL.Clear;
  4.   SQLQuery1.SQL.Text := 'Insert Into TestBigNumbers(ID, Field_Decimal, Field_Numeric, Field_BigInt) ' +
  5.                         'Values (2, 999999999, 999999999, 999999999);';
  6.   SQLQuery1.ExecSQL;
  7.   SQLTransaction1.Commit;
  8.   ShowMessage('OK');
  9. end;

valdir.marcos

  • Hero Member
  • *****
  • Posts: 1106
Re: Lazarus SQLQuery BCDField problem with Firebird
« Reply #4 on: April 26, 2018, 02:08:13 am »
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...

 

TinyPortal © 2005-2018