Using Dataport Functions : Using Functions in C Language Programs : Initializing the Retrieval Process : Automatic Transaction Mode

Automatic Transaction Mode

In automatic_transaction mode, an implicit start_transaction is performed when you initialize the retrieval process and an implicit commit_transaction is performed when you finish the retrieval process.

Whenever you use load and unload functions to change the contents of the database, the program implicitly closes the read transaction, starts the read/write transaction, commits the changes, and implicitly starts a new read transaction.

The following is an example of how to use automatic_transaction:

main()
{
int status, success;
stm_list st_list;
stm_id el;
success = stm_init_uad ("PROJ", "/local/proj",
automatic_transaction, &status);
if (!success)
{
printf ("cause of failure is: %d", status);
return;
}
/* */
/* once initialization is done, */
/* retrieval can be done at any time. */
/* */
st_list = stm_r_st_name_of_st ("*", &status);
for (el = (stm_id)
stm_list_first_element (st_list, 0);el!=NIL;
el =(stm_id)stm_list_next_element (st_list, 0))
{
printf ("\n%s", stm_r_st_name (el, 0));
}
/* */
/* The resulting output is: */
/* state_a */
/* state_b */
/* state_c */
/* state_d */
/* */
stm_finish_uad();