///DELETED PROTOCOL/// SELECT * from AUDIT where Table_name='PROTOCOL' and Reason_modified='DELETED RECORD'; [get record number] SELECT * from PROTOCOL_HISTORY where PROTOCOL_NO=; [get PHID number] Insert into Protocol(protocol_no,unique_id,compatibility_code,method_module, stimulus_module,extra_module,entered_date,protocol_flags,category, description,protocol_data,help_data,total_channels,last_updated,username,reason_modified,serial_no,creation_date) Select protocol_history.protocol_no,protocol_history.unique_id,protocol_history.compatibility_code, protocol_history.method_module,protocol_history.stimulus_module, protocol_history.extra_module,protocol_history.entered_date, protocol_history.protocol_flags,protocol_history.category, protocol_history.description,protocol_history.protocol_data, protocol_history.help_data,protocol_history.total_channels,protocol_history.last_updated,protocol_history.username,protocol_history.reason_modified, protocol_history.serial_no,protocol_history.creation_date from protocol_history where PHID_NO=; /////////////DELETED SUBJECT/////////// SELECT * from AUDIT where Table_name='SUBJECTS' and Reason_modified='DELETED RECORD'; [get record_no] SELECT * from SUBJECTS_HISTORY where SUBJECT_NO=; [get SHID_NO] Insert into SUBJECTS(subject_no,Unique_ID,entered_date,family_name,first_name,dob,hospital_code,initial,title,street,town,state,zipcode,country,telephone,sex,referring_doctor,os_acuity,od_acuity,comment,alias_no,ethnic_origin,category,normal,eye_color,os_refraction,od_refraction,subject_flags,last_updated,user_field1,user_field2,user_field3,username,reason_modified,serial_no,creation_date) Select subjects_history.subject_no,subjects_history.Unique_ID,subjects_history.entered_date,subjects_history.family_name,subjects_history.first_name,subjects_history.dob,subjects_history.hospital_code,subjects_history.initial,subjects_history.title,subjects_history.street,subjects_history.town,subjects_history.state,subjects_history.zipcode,subjects_history.country,subjects_history.telephone,subjects_history.sex,subjects_history.referring_doctor,subjects_history.os_acuity,subjects_history.od_acuity,subjects_history.comment,subjects_history.alias_no,subjects_history.ethnic_origin,subjects_history.category,subjects_history.normal,subjects_history.eye_color,subjects_history.os_refraction,subjects_history.od_refraction,subjects_history.subject_flags,subjects_history.last_updated,subjects_history.user_field1,subjects_history.user_field2,subjects_history.user_field3,subjects_history.username,subjects_history.reason_modified,subjects_history.serial_no,subjects_history.creation_date from subjects_history where SHID_NO=; ///////DELETED TEST ///////// SELECT * from AUDIT where Table_name='TESTS' and Reason_modified='DELETED RECORD'; [get record number] SELECT * from TESTS_HISTORY where TEST_NO=; [get THID_NO] Insert into Tests(test_no,subject_no,Protocol_no,Unique_ID, test_date,examining_doctor,comment,test_data,test_flags, report_data,Last_updated,normal,username,reason_modified, serial_no,creation_date) Select tests_history.test_no,tests_history.subject_no, tests_history.Protocol_no,tests_history.Unique_ID, tests_history.test_date,tests_history.examining_doctor, tests_history.comment,tests_history.test_data, tests_history.test_flags,tests_history.report_data, tests_history.last_updated,tests_history.normal, tests_history.username,tests_history.reason_modified, tests_history.serial_no,tests_history.creation_date from tests_history where THID_NO=;