|
Purpose |
Obtains a connection handle from the database manager to be used in subsequent calls to DP4 functions. | |
|
Syntax |
int srv_init_process(void) | |
|
Description |
The srv_init_process() obtains a connection handle from the database manager. In C programs this function is usually called in the main() function implementation in the C library, and not called directly. The function is implemented by a call to tail_get_option() to check for the presence of the -server_name command tail, followed by an appropriate call to srv_connect(). srv_enable() must be called after srv_init_process() to enable the process to call database or file functions within the the database manager. | |
|
Return values |
Returns a positive value, also assigned to df_process if a connection is successfully obtained, or -1 otherwise. | |
|
See also |
||
|
Example |
An application program may acquire multiple process numbers in order to be able to process two transactions independently. For example a program designed for an order entry system might wish to update orders, but also maintain statistics about the programs usage, and it would be desirable to be able to update the statistics tables in the middle of an order transaction without updating the order. This can be achieved as follows.
void update_statistics()
{
int save_process = df_process;
int save_db_nr = db_nr;
if (srv_init_process() > 0)
{
srv_enable();
db_open(dbname,db_generation,SHARED);
/* perform updates -does not affect transaction in progress at call to
srv_init_process */
db_close();
srv_disable();
srv_end_process();
}
df_process = save_process;
db_nr = save_db_nr;
}
The code could be improved by moving the code to open and close the second process to outside the update_statisitics() function and toggling the df_process and db_nr variables (in a similar way to the technique used for multiple dbs) |
|