URL: http://www.firstbasesoftware.com/man/man3/foreach.htm
Last modified: 12 September 1995
Copyright © by FirstBase Software.
[ Index of Contents] [ FirstBase RDBMS Overview]


NAME

foreach, forxeach, blockeach - function processing of index/database

SYNOPSIS

#include <firstbase/fb.h>

fb_foreach(db, f)
fb_database *db;
int (*f)();

fb_forxeach(db, f)
fb_database *db;
int (*f)();

fb_blockeach(db, f)
fb_database *db;
int (*f)();

DESCRIPTION

Fb_foreach, fb_forxeach, and fb_blockeach provide very useful methods for processing multiple records in a database. These routines will call a separately defined function exactly once for each referenced record in the database.

The idea is to create a separate function, f, that takes exactly one argument -- an fb_database pointer. This function must return the FB_AOK signal on correct completion, and FB_ERROR on an incorrect completion.

The function f is then passed into foreach, forxeach or blockeach as an argument. These routines do the actual looping through the database. The only difference between foreach and forxeach is which records are accessed: foreach will process the entire database whereas forxeach will follow the database index loaded into the db structure, calling f only for those records that the index references.

Blockeach is essentially the same as foreach, but record blocking is used to provide extremely fast throughput. However, blockeach does not follow the database map, meaning the "record number" is actually a positional number. If the database is clean (as in dbclean(1)) this number will be the same as the true (database map) record number. Alternately, in many cases the application program does not need the true record number. If blockeach can be used within these constraints, record processing will be much faster.

SEE ALSO

getrec(3), opendb(3), database(4), index(4).

DIAGNOSTICS

All of these routines will return the FB_AOK signal when the end of the database or index is reached. If f returns an FB_ERROR signal, the looping process is halted, and an FB_ERROR signal is returned to the caller.


URL: http://www.firstbasesoftware.com/man/man3/foreach.htm
Last modified: 12 September 1995
Copyright © by FirstBase Software.
[ Index of Contents] [ FirstBase RDBMS Overview]