The following programs demonstrate the use of the COUNT function
in a display statement. These programs:
o Use the COUNT function to compute the number of records stored
in the EMPLOYEES relation
o Print an informational message and this computed number
1 – C Example
#include <stdio.h>
DATABASE PERS = FILENAME "PERSONNEL";
int num;
main()
{
READY PERS;
START_TRANSACTION READ_ONLY;
GET
num = COUNT OF E IN EMPLOYEES;
END_GET;
printf ("The number of employees is %d", num);
COMMIT;
FINISH;
}
2 – Pascal Example
program display_count (input,output);
DATABASE PERS = FILENAME 'PERSONNEL';
var
num : integer;
begin
READY PERS;
START_TRANSACTION READ_ONLY;
GET
num = COUNT OF E IN EMPLOYEES;
END_GET;
writeln ('The number of employees is', num);
COMMIT;
FINISH;
end.