#include "db.h" int dbgetv(Dbptr db, char *table_name, char *field_name, void *value1, [ char *field_name2, void *value2, ... ] NULL) int dbputv(Dbptr db, char *table_name, char *field_name, Type value1, [ char *field_name2, Type value2, ... ] NULL) long dbaddv(Dbptr db, char *table_name, char *field_name, Type value1, [ char *field_name2, Type value2, ... ] NULL)
When db refers to a view, a base table name may be given for field_name; this returns the database pointer for the corresponding record in that base table.
dbaddv adds a new record to a plain table (not a view), filling in the specified fields, just as dbputv does. However, the new record is first filled with null values, and the schema's Timedate field (lddate for css3.0) is filled in before the values from the call. Hence, you can write your own value into the Timedate field, overriding the default operation.
dbaddv checks to ensure that the primary and alternate key for the record are completely filled in (no null fields allowed, except for offdate and endtime), and unique. However, you may leave out an id field that is a primary key, e.g. wfid in wfdisc or arid in arrival, and the field is filled using dbnextid(3).
If the record you provide is not unique, i.e., there is another record with the same primary or alternate key in the table, the table is not updated. dbaddv goes on to compare all the fields in the record. If all of the fields are either the same, or the new record has a null value, then dbaddv returns the record number of the matching record. If there is a discrepancy in some field of the matching record, then dbaddv returns a negative value which is equal to dbINVALID - matching_record_number - 1.
dbaddv uses the scratch record to hold the new record before adding it to the table, so any previous contents of the record are lost.
The database pointer db must specify the database and record number (dbputv and dbgetv only), and may specify the table number. Alternatively, the table may be specified in the table_name argument, and the field name(s) must be specified by the field_name arguments. The variable argument list is terminated with a value of zero for a field_name.
dbputv returns 0 on success, dbINVALID otherwise.
dbgetv returns 0 on success, dbINVALID otherwise.
dbaddv returns the record number of the added record if it's successful, and a number less than zero if it fails. Negative return values are either dbINVALID, or dbINVALID - matching_record_number - 1, as described above.
Failure for dbputv and dbaddv includes overflow of the output database field. This can happen if a number or string is too large to fit into the space allotted.
dbaddv uses the scratch record, which means its previous contents are lost.
While dbputv updates the Timedate field (if it exists) for a record, dbput does not. Setting ELOG_SIGNALS to null also shuts off signal handlers in dbgetv, dbputv, and dbaddv that intercept failures from unexpected truncation of database tables.