/* Copyright © Oracle Corporation 1995. All Rights Reserved. */ /***************************************************************************** * This routine transfers an employee from the WEST database to the EAST * database. It expects the distributed context structure as a parameter * The employee record is selected first, deleted from the EAST database * and inserted into the WEST database * *****************************************************************************/ #include #include #include #include #include struct context_struct { long version; long type; long length; long distributed_tid[4]; long end; }; char last_name[15], first_name[11], middle_initial[2],address1[26], city[21],state[3],zip[6],sex[2],emp_birth[8]; char emp_id[6]; long sqlcode; void sql$dist_trans_error (struct context_struct *context); void start_2db(); void delete_west(); void select_west(); void insert_east(); transfer_east(struct context_struct *context) { struct context_struct local_context; local_context = *context; printf("\nStarting Transaction on EAST and WEST\n "); start_2db(&sqlcode,&local_context); if (sqlcode != 0) sql$dist_trans_error(&local_context); printf("\nSelecting the record from the WEST database \n"); select_west(&sqlcode,&emp_id,&last_name,&first_name, &middle_initial,&address1,&city, &state,&zip,&sex,&emp_birth,&local_context); if (sqlcode != 0) { printf("\nFailed at select_west \n"); sql$dist_trans_error(&local_context); return; } printf("\nDeleting the record from the WEST database \n"); delete_west(&sqlcode,&emp_id,&local_context); if (sqlcode != 0) { printf("\nFailed at delete_west \n"); sql$dist_trans_error(&local_context); return; } printf("Inserting the record in the EAST database \n"); insert_east(&sqlcode,&emp_id,&last_name,&first_name, &middle_initial,&address1,&city, &state,&zip,&sex,&emp_birth,&local_context); if (sqlcode != 0) { printf("\nFailed at insert_east \n"); sql$dist_trans_error(&local_context); return; } return; }