Sample Program : Program Description : Main Section and Program Setup

Main Section and Program Setup
main( )

This section is the main part of the program. It calls the individual routines that are included in the C program.

{
char pname[32];
printf("enter name of project: ");
GET_STR(pname);

The program begins by prompting for the name of the project.

success=stm_init_uad(pname,"/usr/sam/proj",
self_transaction,&status);

The extraction is initialized by this function call. Your user’s authorization to use the database is checked. You must be a member of the project that contains the specified activity-chart. If you are a member, the database is opened.

The parameter value self_transaction declares that you control the transaction handling, rather than having it done automatically. If the function is not successful, check the value of status to find out the reason for the failure.

stm_start_transaction();

This statement permits database operations. The statement must appear here because the self_transaction parameter was used in the init statement.

activity_boxes();

This calls the primary routine.

stm_commit_transaction();
stm_finish_uad();
}

This example does not have functions that write to the database; therefore, the commit statement here serves only to conclude the transactions.

The finish statement concludes the Dataport operations and closes the database.