20 August 2014
 Home | Forum | Downloads | Business Directory | Product Directory | How Tos | Blogs | Jobs 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
lrecTableInfo.FIND('-');
REPEAT
  ldecDbUsed := ldecDbUsed + lrecTableInfo."Size (KB)";
UNTIL lrecTableInfo.NEXT = 0;

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

EXIT(ldecDbUsed);

fctGetDbSize() : Decimal
lrecDbFile.FIND('-');
REPEAT
  ldecDbSize := ldecDbSize + lrecDbFile."Size (KB)";
UNTIL lrecDbFile.NEXT = 0;
EXIT(ldecDbSize);

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

 

 Download code

Author: Luc Van Dyck
Date: 03/03/2003
Size: 4.2 KB
Downloads: 1986
Views: 8835  (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.
   poor



   excellent



Copyright © 1999-2014 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.