Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PROCEDURE invertVehicleInfo(p_source_vehicle_id IN NUMBER, p_dest_vehicle_id IN NUMBER, p_date IN DATE) IS
- v_source_remote_unit_id NUMBER(10);
- v_dest_remote_unit_id NUMBER(10);
- v_source_remote_unit_identifier VARCHAR2(50);
- v_dest_remote_unit_identifier VARCHAR2(50);
- v_src_last_vehicle_data_id NUMBER(10);
- v_dest_last_vehicle_data_id NUMBER(10);
- CURSOR srcVehicleRecords_c IS
- SELECT vehicle_data_id
- FROM vehicle_data
- WHERE vehicle_id = p_source_vehicle_id
- AND gps_full_date > p_date;
- CURSOR destVehicleRecords_c IS
- SELECT vehicle_data_id
- FROM vehicle_data
- WHERE vehicle_id = p_dest_vehicle_id
- AND gps_full_date > p_date;
- BEGIN
- SELECT remote_unit_id
- INTO v_source_remote_unit_id
- FROM vehicle
- WHERE vehicle_id = p_source_vehicle_id;
- SELECT remote_unit_id
- INTO v_dest_remote_unit_id
- FROM vehicle
- WHERE vehicle_id = p_dest_vehicle_id;
- SELECT IMEI
- INTO v_source_remote_unit_identifier
- FROM remote_unit
- WHERE remote_unit_id = v_source_remote_unit_id;
- SELECT IMEI
- INTO v_dest_remote_unit_identifier
- FROM remote_unit
- WHERE remote_unit_id = v_dest_remote_unit_id;
- SELECT MAX(vehicle_data_id)
- INTO v_src_last_vehicle_data_id
- FROM vehicle_data
- WHERE vehicle_id = p_source_vehicle_id;
- SELECT MAX(vehicle_data_id)
- INTO v_dest_last_vehicle_data_id
- FROM vehicle_data
- WHERE vehicle_id = p_dest_vehicle_id;
- FOR srcVehicleRecords_r IN srcVehicleRecords_c
- LOOP
- UPDATE vehicle_data
- SET remote_unit_identifier = v_dest_remote_unit_identifier,
- vehicle_id = p_dest_vehicle_id,
- remote_unit_id = v_dest_remote_unit_id
- WHERE vehicle_data_id = srcVehicleRecords_r.vehicle_data_id;
- END LOOP;
- FOR srcVehicleRecords_r IN srcVehicleRecords_c
- LOOP
- UPDATE vehicle_data
- SET remote_unit_identifier = v_source_remote_unit_identifier,
- vehicle_id = p_source_vehicle_id,
- remote_unit_id = v_source_remote_unit_id
- WHERE vehicle_data_id = srcVehicleRecords_r.vehicle_data_id;
- END LOOP;
- END;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement