| |

VerySource

 Forgot password?
 Register
Search
View: 26|Reply: 13

decimal (20, 8) can only be displayed as TFloatField (EnableBCD = false) or TBCDField in dataset

[Copy link]

1

Threads

27

Posts

24

Credits

Newbie

Rank: 1

Credits
24

 China

Post time: 2020-1-29 08:00:01
| Show all posts |Read mode
decimal (20, 8) can only be displayed in the dataset as TFloatField (EnableBCD = false) or TBCDField:
1, if using TBCDField, only 4 decimal places can be displayed and input;

2. If TFloatField is used, there can only be 15 significant digits, which cannot meet the accuracy requirements

How to use TFMTBCDField, or other ways to achieve display and input 20-digit precision, 8 decimal places?
Reply

Use magic Report

0

Threads

9

Posts

10

Credits

Newbie

Rank: 1

Credits
10

 China

Post time: 2020-5-4 08:30:01
| Show all posts
Connect to the database via ADO
Reply

Use magic Report

1

Threads

27

Posts

24

Credits

Newbie

Rank: 1

Credits
24

 China

 Author| Post time: 2020-5-10 19:00:01
| Show all posts
Is to connect to sql server through ado
The field type generated in the DataSet can only be TFloatField or TBCDField
Can not meet the precision and decimal requirements of decimal (20, 8)
Reply

Use magic Report

0

Threads

9

Posts

10

Credits

Newbie

Rank: 1

Credits
10

 China

Post time: 2020-5-25 13:45:01
| Show all posts
I really convinced you, is it that in Delphi only these fields store numbers? Can't you use strings?
All 32 decimal places have been done.
Reply

Use magic Report

1

Threads

27

Posts

24

Credits

Newbie

Rank: 1

Credits
24

 China

 Author| Post time: 2020-5-28 17:15:01
| Show all posts
Don't worry upstairs

This is a three-layer structure, and the DataSet field is not manually added, and it is not realistic to add all fields in the entire system manually.

Can you introduce your approach? Thanks a lot!
Reply

Use magic Report

1

Threads

27

Posts

24

Credits

Newbie

Rank: 1

Credits
24

 China

 Author| Post time: 2020-5-29 08:15:01
| Show all posts
Make another statement:

Only decimal can be used in the database, not varchar, because the database has high speed requirements, the number of concurrent per second is very large, need to be calculated, varchar and decimal are very different.
Reply

Use magic Report

1

Threads

27

Posts

24

Credits

Newbie

Rank: 1

Credits
24

 China

 Author| Post time: 2020-5-29 13:00:01
| Show all posts
In addition, manually add a field in adoquery of Delphi, specify the type String
There will be errors when opening query:
Type mismatch for field '' excepting: String actual: BCD.



PleaseWayWonto introduce your approach, thank you very much!
Reply

Use magic Report

0

Threads

9

Posts

10

Credits

Newbie

Rank: 1

Credits
10

 China

Post time: 2020-6-28 18:15:01
| Show all posts
Where to calculate?

If you can calculate it directly, you can set the field type to TCurrencyField in Delphi.
Don't want to show the symbol
Currency:=False;
But pay attention
DisplayWidth:=20
It’s your field length, I don’t need to say the rest

As for the manual addition problem, this is very simple. It is impossible for all your tables to have this field. You can adjust the default TBCDField to TCurrencyField for these fields by dynamically adding fields.
Reply

Use magic Report

1

Threads

27

Posts

24

Credits

Newbie

Rank: 1

Credits
24

 China

 Author| Post time: 2020-7-19 20:15:01
| Show all posts
I think the one upstairs did not understand my question.

my question is:
How to input the data type of decimal(20, 8) in the database on the client does not consider changing the decimal of the database to other types. How can you enter a number with 12 integers and 8 decimal places.
TCurrencyField is essentially TFloatField, the only difference is that its field type is ftCurrency.

The precision of TFloatField is 15 digits, and the precision of decimal(20,8) is 20 digits. For example, enter the value 123456789012.12345678 on the client. This value is legal for decimal(20,8) and can be directly entered in the database. But the precision of TFloatField and TCurrencyField is 15 digits. When saving, it will ignore the excess digits and only save 123456789012.123 to the database. I have tested TCurrencyField and TFloatField.

If you manually add fields, you will have Type mismatch for field'' excepting: String actual: BCD. error if the type is defined as String.

If you manually add fields and define the type as Variant, it can be implemented, but it is limited to adding in adoquery. In the 3-layer structure, add a variant type field to adoquery, and then open the DataSet in TClientDataSet or add a field. It will prompt adoquery. The field type of the variant type is undefined.
Reply

Use magic Report

0

Threads

7

Posts

7

Credits

Newbie

Rank: 1

Credits
7

 China

Post time: 2020-7-21 05:15:01
| Show all posts
WayWon, Xiongtai is better to experiment.
Currency type decimals only save four digits,
The accuracy of the floating point is indeed 15 bits. According to the requirements of the landlord, I have tested it and cannot save the required accuracy
If you want to use characters, you must make the database type consistent with the type in the program.
There is also the hateful decimal type, which can be stored in the database after eight decimal places. But only four bits are saved in delphi. Even if the attribute is set. I read the post of the original poster, but I haven't found the perfect solution yet!
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2020|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list