insert into cdr(local_ip_v4, caller_id_name, caller_id_number, destination_number, context, start_stamp, answer_stamp, end_stamp, duration, billsec, hangup_cause, uuid, bleg_uuid, accountcode, read_codec, write_codec, sip_hangup_disposition, ani, channel_name, d_company, l_company, d_user, l_user, cfwd, recording) (select local_ip_v4, caller_id_name, caller_id_number, destination_number, context, start_stamp, answer_stamp, end_stamp, duration, billsec, hangup_cause, uuid, bleg_uuid, accountcode, read_codec, write_codec, sip_hangup_disposition, ani, channel_name, d_company, l_company, d_user, l_user, cfwd, recording from cdr_2 where (local_ip_v4, caller_id_name, caller_id_number, destination_number, context, start_stamp, answer_stamp, end_stamp, duration, billsec, hangup_cause, uuid, bleg_uuid, accountcode, read_codec, write_codec, sip_hangup_disposition, ani, channel_name, d_company, l_company, d_user, l_user, cfwd, recording) not in (select local_ip_v4, caller_id_name, caller_id_number, destination_number, context, start_stamp, answer_stamp, end_stamp, duration, billsec, hangup_cause, uuid, bleg_uuid, accountcode, read_codec, write_codec, sip_hangup_disposition, ani, channel_name, d_company, l_company, d_user, l_user, cfwd, recording from cdr where start_stamp >= now() - interval '14 days'));
