You can format the output for your database size estimation. Sub-objects (such as columns and indexes) contained in a table are offset, and you can print additional information after the total.
The syntax for the output is as follows:
[object-size][:compartment]|[ObjectID][|label]
where:
- object-size - is the size of the object.
- compartment - is a one-digit number, which indicates that the size of the object should be excluded from the total size of the database and should be printed after the database size has been calculated. For example, you may include the size of individual tables in your calculation of the database size and print the sizes of tablespaces separately after the calculation.
- ObjectID - is unneccessary for objects, such as tables, but required for sub-objects if you want to print them to the Result List.
- label - is any appropriate identifying string, and is generally set to ShortDescription, which prints the type and name of the selected object.
For example, in the event handler defined on the
Table metaclass (having calculated and stored the size of a table, the size of all the columns of type LONG contained in the table, and the size of each index in the table), we create a message variable to print this information. We begin by printing a line giving the size of a table:
message = CStr(TableSize) & "||" & objTable.ShortDescription & vbCrLf
We then add a line printing the total size of all the columns of type LONG in the table:
message = message & CStr(LongSize) & "||Columns of type LONG" & vbCrLf
We then add a line printing the size of each index in the table:
message = message & CStr(IndexSize) & "|" & objIndex.ObjectID & vbCrLf
In the event handler defined on the Tablespace metaclass (having calculated and stored the size of a tablespace), we create a message variable to print this information after the database size calculation has been printed.
We begin by overriding the default introduction to this second compartment:
message = ":1||Tables are allocated to the following tablespaces:"
We then add a line printing the size of each tablespace in the table
message = message + CStr(tablespaceSize) & ":1||" & objTablespace.ShortDescription
The result gives the following output:
Estimate of the size of the Database "Sales"...
Number Estimated size Object
------- -------------- ------------------------------------
10,000 6096 KB Table 'Invoices'
Columns of type LONG (35 KB)
Index 'customerFKeyIndex' (976 KB)
Index 'descriptionIndex' (1976 KB)
[...etc...]
Tables are allocated to the following tablespaces:
Estimated size Object
-------------- ------------------------------------
6096 KB Tablespace 'mainStorage'
[...etc...]