1 August 2015
 Home | Forum | Downloads | Business Directory | Product Directory | How Tos | Blogs Feedback 
Become a sponsor
Our sponsors

How Tos

How To calculate database usage?

Author: Luc Van Dyck

Sometimes you want to give a warning when database usage is getting close to the database size.
eg. For large batch operations, it becomes almost impossible to execute properly, when the database has reached 99% of the database size.

Therefore you need to calculate the database usage and database size, using C/AL code.

These routines does just that, but they can't be 100% accurate. This is caused by BLOB-fields in objects, as they are stored in a compressed form (by using a pkzip algorithm and removing 0's and trailing blanks). Hence there is a difference in the used (KB) figures according to the Database - Information form.

fctGetDbUsage() : Decimal
  ldecDbUsed := ldecDbUsed + lrecTableInfo."Size (KB)";
UNTIL lrecTableInfo.NEXT = 0;

  ldecDbUsed := ldecDbUsed + (lrecObject."BLOB Size" / 1024);
UNTIL lrecObject.NEXT = 0;


fctGetDbSize() : Decimal
  ldecDbSize := ldecDbSize + lrecDbFile."Size (KB)";
UNTIL lrecDbFile.NEXT = 0;

fctGetDbName() : Text[250]
EXIT(lrecDbFile."File Name");


 Download code

Author: Luc Van Dyck
Date: 03/03/2003
Size: 4.2 KB
Downloads: 2045
Views: 9542  (Page views are only logged since 3 May 2005)
Avg. rating:  (rated 17 times)
Discuss this How To in the forum (1 reaction)
What's this MUID? [MUID:PYCY]  SMS this title to a friend
 Mail this title to a friend
Rate this HowTo
- Please do not vote for the same HowTo more than once.
- Please be objective.


Copyright © 1999-2015 mibuso.com. All rights reserved. About | Disclaimer | Privacy Policy | Sales Terms & Conditions
mibuso.com is not in any way affiliated or associated with Microsoft Corporation or any of the companies in the Microsoft Corporation Group.