/* Copyright © Oracle Corporation 1995. All Rights Reserved. */ /**************************************************************************** * RDB_ADD_WEST.SC * * This routine is called from the main program to add an employee to the * WEST database. It expects two parameters: the distributed context structure * and the employee record structure. * *****************************************************************************/ #include #include #include #include #include EXEC SQL INCLUDE SQLCA; EXEC SQL DECLARE WEST ALIAS FOR FILENAME 2pcwest; struct context_struct { long version; long type; long length; long distributed_tid[4]; long end; }; struct employ_struct { char emp_id[6]; char emp_last_name[15]; char emp_first_name[11]; char emp_middle_initial[2]; char emp_address1[26]; char emp_city[21]; char emp_state[3]; char emp_zip[6]; char emp_sex[2]; char emp_birth[8]; }; long sqlcode; void sql$dist_trans_error (struct context_struct *context); int status; short iosb[4]; void rdb_add_west(struct context_struct *context, struct employ_struct *employee) { struct context_struct local_context; struct employ_struct local_employee; local_context = *context; local_employee = *employee; EXEC SQL WHENEVER SQLERROR GOTO handle_error; EXEC SQL USING CONTEXT :local_context INSERT INTO west.EMPLOYEES (EMPLOYEE_ID,LAST_NAME,FIRST_NAME,MIDDLE_INITIAL, ADDRESS_DATA_1,CITY,STATE, POSTAL_CODE, SEX, BIRTHDAY) VALUES (:local_employee.emp_id, :local_employee.emp_last_name, :local_employee.emp_first_name, :local_employee.emp_middle_initial, :local_employee.emp_address1, :local_employee.emp_city, :local_employee.emp_state, :local_employee.emp_zip, :local_employee.emp_sex, :local_employee.emp_birth); return; handle_error: printf ("\n %% Error occurred in ADD_WEST " ); sql$dist_trans_error(&local_context); return; }