NAME
dbnextid - generate a unique id from the lastid table
SYNOPSIS
#include "db.h"
long dbnextid(Dbptr db, char *name)
DESCRIPTION
dbnextid returns the next available integer for the specified
(field)
name. When no
dbids(1) id server is specified,
it looks up the current value in the lastid table,
increments that by one, updates the lastid table, and
returns the incremented value. If no entry is found in the table
corresponding to the
name, a new entry is created, and its value set
to one.
When a dbids(1) server has been specified for the database, dbnextids opens a connection
to the dbids(1) server and obtains a new id.
If the specified field name is a Unique key in a table
and no entry exists in lastid,
that table is searched and the next available id found.
The lastid table is updated appropriately.
FILES
Updates the lastid table.
RETURN VALUES
Returns a positive integer on success, and -1 in the event the lastid
table cannot be updated. More detailed error messages may be present
in the log (see
register_error(3)).
LIBRARY
$(DBLIBS)
SEE ALSO
dbintro(3)
BUGS AND CAVEATS
In the css3.0 schema, ids are 8 characters, making the maximum id 99999999; when
this limit is reached, the ids must be renumbered.
AUTHOR
Daniel Quinlan