do $$
declare
    _id_ct_ctb_cap_soc_int integer;
    _id_ct_ctb_cap_soc_sub integer;
    _list refcursor;
    _item record;
begin

    open _list for
        select *
        from tb_part
        where
            tp_part like '%[CO]%' and
            (id_ct_ctb_cap_soc_int is not null or
             id_ct_ctb_cap_soc_sub is not null);
            
    fetch _list into _item;
    
    while found loop
        _id_ct_ctb_cap_soc_int := _item.id_ct_ctb_cap_soc_int;
        _id_ct_ctb_cap_soc_sub := _item.id_ct_ctb_cap_soc_sub;
        
        
        update tb_part set
            id_ct_ctb_cap_soc_int = _id_ct_ctb_cap_soc_sub,
            id_ct_ctb_cap_soc_sub = _id_ct_ctb_cap_soc_int
        where
            id_part = _item.id_part;
        
    
        fetch _list into _item;
    end loop;
        
end;
$$