How Do I Determine the Bulk Size When Fetching Records from a Database Table? (Magic xpa 4.x)
Sometimes you may want to know the size of a database table. There are three functions to do this:
-
DbSize() returns the size of the table, in bytes.
-
DbRecs() returns the number of records in the table.
-
DbViewSize() returns the number of records in the current data view.
Each of these works slightly differently, as explained below.
DbSize() is used when you want to determine the size of the table in bytes. The syntax is:
DbSize(dsource#, tablespec)
where:
-
dsource# is sequence number of the table in the Data repository.
-
tablespec is the name of the table, if you want to specify a different one than the default.
In this example,
DbSize('1'DSOURCE,'')
returns 19,470, the byte size of the table.
DbRecs() is used when you want to determine the number of records in the table. The syntax is:
DbRecs (dsource#, tablespec)
where:
-
dsource# is sequence number of the table in the Data repository.
-
tablespec is the name of the table, if you want to specify a different one than the default.
In this example,
DbRecs('1'DSOURCE,'')
returns 33, the total number of records in the table.
DbViewSize() is used when you want to determine the number of records in the current data view. The syntax is:
DbViewSize (generation)
where:
In this example,
DbViewSize(0)
returns 12, the total number of records in the table. This is because, although there are 33 records in the table, the user has used a Range to show only the records beginning with the letter ‘T’.