我需要制作两个游标或一个游标和一个循环。但一个人必须在其他人之内。我正在尝试使用两个游标并使用for但不认识我外部游标的名称表的变量值。 你可以帮帮我吗?你能建议我做这些的最佳方法吗?我是pl / sql的新手。谢谢。我把代码:
DECLARE
TABLENAME VARCHAR2(30);
LINK VARCHAR2(30);
CURSOR FIRST_SELECT IS
SELECT A.TABLE_NAME AS TABLENAME, B.LINK AS LINK
FROM ALL_TABLES A, TABLE_CONNECT_LINK B
WHERE A.TABLE_NAME=B.COMPARE_TABLE;
BEGIN
OPEN FIRST_SELECT;
LOOP
FETCH FIRST_SELECT INTO TABLENAME,LINK;
EXIT WHEN FIRST_SELECT%NOTFOUND;
DECLARE
PEPELU VARCHAR2(4000);
TABLE VARCHAR2(70);
stringconsult VARCHAR2(4000);
COMPONENTE NUMBER(5);
TABLE_INSERTAR VARCHAR2(30);
COLUMN VARCHAR2(30);
OWNER VARCHAR2(30);
CURSOR ALL IS
SELECT TABLE,COLUMN,OWNER FROM TABLENAME;
BEGIN
OPEN ALL;
LOOP
FETCH ALL INTO TABLE,COLUMN,OWNER;
EXIT WHEN ALL%NOTFOUND;
stringconsult:='select ' || owner||','|| TABLE||','|| COLUMN||' from ' || INSERTNAME || ' minus select owner, table_name, column_name from all_tab_columns@'|| LINK||'';
DBMS_OUTPUT.PUT_LINE(stringconsult || ';');
DBMS_OUTPUT.PUT_LINE('COMMIT;');
COMMIT;
END LOOP;
CLOSE ALL;
END;
END LOOP;
CLOSE FIRST_SELECT;
END;
/