|
Purpose |
Posts a record to a database | |
|
Old name |
#define post rec_post_with_flags | |
|
Syntax (CCOWN) |
void rec_post_with_flags(short * datarec, int flags) | |
|
Syntax (DP4DBAPI) |
BOOLEAN dp4_rec_post(DCONN *dconn,short *datarec,int flags) | |
|
Parameters |
DCONN * dconn |
Handle to database connection |
|
short* datarec |
Pointer to the .l field of the table record to be posted | |
|
|
int flags |
Indicates what checks should be made |
|
|
The parameter flags can take any combination of the values below: | |
|
|
Value |
Meaning |
|
|
CHECK_PARENT |
A subsequent commit fails on this record if the parent is missing in any of the indexes marked for parent checking |
|
|
VERIFY_PARENT |
A subsequent commit fails if the parent is either missing or has been updated since the start of the transaction in any of the indexes marked for parent verification. (This is equivalent to calling rec_verify() for each such parent) |
|
|
CHECK_CHANGE |
A subsequent commit fails if the record being posted is an amendment of an existing record, and any of the keys in secondary indexes marked for change-prevention have been changed |
|
|
The following values can also be added to flags: | |
|
|
Value |
Meaning |
|
|
UPDATE_ONLY |
Causes a commit failure if the record is not already on the database |
|
|
POST_UNCHANGED |
Causes the time stamp to be updated even if the record is unchanged |
|
|
NO_AUTOINC |
If the table is an autoinc table, the value of the autoincrementing key is not marked as used, so that the same value is returned again on a subsequent call to the function rec_autoinc() |
|
|
NO_FINDLIST |
No entry is made in the internal table containing the details of the last record found |
|
|
The following value can be used if none of the above flags are required: | |
|
|
Value |
Meaning |
|
|
NO_CHECK |
No parent checking is done |
|
Description |
The specified data record is posted to the database. If a record already exists which matches on the prime index, it is replaced; otherwise, a new record is inserted. A call to either the db_commit() or db_checkpoint() function must be made to write the record to the database permanently. The calling application can subsequently read this record from the database before a call to either the db_commit() or db_checkpoint() function, using any of the fetch() functions if either the "flags" parameter to the fetch is set to the value EQUAL, or the private database mode was specified when the database was opened. The updated record will not be visible to fetch functions other than EQUAL fetches unless the private database facility is used. C programs using LIBMAKE generated code to open the database can enable the private database facility by using the LIBMAKE directive #private, otherwise pass PRIVATE_DB to the db_open() function. Other processes are not able to read the updated record until either the db_commit() or db_checkpoint() function is called. If the record already exists they will see the prior state of the record. The checks specified in the parameter flags are done when the records are written to the database with a call to either the db_commit() or db_checkpoint() function. The checks are not done by the post function itself. Parent checking is usually done by the program while user is entering particular field values, so it is relatively unusual for any value other than NO_CHECK to be used with the parameter flags. Unnecessary rpovessing is avoided in the following ways:
| |
|
See also |
db_commit(), db_checkpoint(), rec_kill(), db_decommit(), rec_verify(), rec_autoinc() | |
|
Example |
rec_post_with_flags(&order_line.l,NO_CHECK); | |