UPDATE info@REMOTE_CONNECT SET
USER_GRADE_ID =
(select a.USER_GRADE_ID from info a, info@REMOTE_CONNECT b
where a.USER_GRADE_ID =b.USER_GRADE_ID and rownum<2)
--查找总ID
cursor cur_id is select id from info@REMOTE_CONNECT;
BEGIN
v_count := 0;
open cur_id;
fetch cur_id into v_id;
while cur_id%found loop
--取出原有数据,插入变量中:
SELECT USER_GRADE_ID
INTO v_user_grade_old
FROM info@REMOTE_CONNECT
WHERE id = v_id;
--取出更新后的数据,插入变量中:
SELECT USER_GRADE_ID
INTO v_user_grade_new
FROM info
WHERE id = v_id;
IF v_user_grade_old <> v_user_grade_new THEN
v_count := v_count + 1;--更新记录数加一
--还原数据
UPDATE info@REMOTE_CONNECT SET
USER_GRADE_ID = v_user_grade_new
WHERE id = v_id;
commit;
END IF;
fetch cur_id into v_id;
end loop;
close cur_id;
dbms_output.put_line('更新的记录数为:' || v_count);
--查找总ID
cursor cur_id is select id from info@REMOTE_CONNECT;
BEGIN
v_count := 0;
open cur_id;
fetch cur_id into v_id;
while cur_id%found loop
--取出原有数据,插入变量中:
SELECT USER_GRADE_ID
INTO v_user_grade_old
FROM info@REMOTE_CONNECT
WHERE id = v_id;
--取出更新后的数据,插入变量中:
SELECT USER_GRADE_ID
INTO v_user_grade_new
FROM info
WHERE id = v_id;
IF v_user_grade_old <> v_user_grade_new THEN
v_count := v_count + 1;--更新记录数加一
--还原数据
UPDATE info@REMOTE_CONNECT SET
USER_GRADE_ID = v_user_grade_new
WHERE id = v_id;
END IF;
fetch cur_id into v_id;
end loop;
close cur_id;
dbms_output.put_line('更新的记录数为:' || v_count);
commit;
END P_REVERT;
/