Scale on MDB Currency type reset to 2 instead 4

Posts   
 
    
Puser
User
Posts: 228
Joined: 20-Sep-2012
# Posted on: 01-Feb-2013 13:42:32   

How to fix the problem with the scale (see starting in thread http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=21630). I know I changed it at the Catalog side before in earlier LLBLGen version of may 2012 and that worked, but now it refreshes also again from the DB. Let me try to explain:

I have lots of Currency fields in my Access DB. These are all scale 4 (no matter if I set the property 'Decimal places' in Access, this setting only effects display in tables and queries - setting 'Decimal places' is ignored by LLBLGen, that's fine) So all my calculations work with 4 decimals and if I want to save only 2 decimals I round to two in my code and if I dont, then with 4 decimals.

So, how can I use 4 decimals? Setting it in the Catalog is useles because the next refresh it is reset to 2. I tried the setting 'Length precision scale follow dblength precision scale' both True or False but always set it to 2 decimals. Do I need a filter, converter, a hidden setting?

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 02-Feb-2013 05:56:13   

As your previous post, now in v3.x there is two concepts: Catalog and Model. The catalog is your DB representation, so you can't have different scale/precision of that in your DB there. The Model is different, the model represents the entities you will use as objects in your code. The model may be different of your Catalog, for instance: different names, different mandatory fields (IsOptional), model-only relationships, value types, etc.

The Length precision scale follow db length precision scale Project setting should work indeed, but only if you do the change in the Model. If you do the change in your catalog explorer, LLBLGen thinks you actually want to change the DB, that's why LLBLGen will ask you to generate a schema update sql script.

I'm not sure where are you doing that change. However doing a Model entity field precision = 4 where the Catalog says precision=2 might cause SQL overflows errors. If LLBLGen is reseting the precision to 2 is for a reason, Are you sure your DB have all precision to 4?

David Elizondo | LLBLGen Support Team
Puser
User
Posts: 228
Joined: 20-Sep-2012
# Posted on: 05-Feb-2013 17:30:55   

Sorry David,

With all trouble I had before and installing/removing subsequent versions I forgot I had made an adjustment in the AccessSchemaRetriever as mentioned in http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=18534 by Frans.

Like David said above, if you use Currency, the scale is not reported by access, so we set it to 2. If you use numeric instead, the scale IS reported. If you want it to be 4, please compile the msaccess driver from sourcecode, and change the line 296 in AccessSchemaRetriever from 2 to 4.

I will change this in the new source code, and try my luck again simple_smile

Keep you posted. Niels

Puser
User
Posts: 228
Joined: 20-Sep-2012
# Posted on: 05-Feb-2013 17:35:11   

It works!

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 05-Feb-2013 17:44:46   

That's great news simple_smile

Frans Bouma | Lead developer LLBLGen Pro