我有兩個遊標c11和c2。我有兩個表compare1和compare2.Both具有相同的列但值不同。我想將c1的結果傳遞給c2遊標。我正在從user_tab_columns獲取表的列名。我想傳遞列名以獲取比較1和比較2表之間唯一記錄的差異。但是來自c1的列名不會傳遞給c2.Please找到我嘗試過的代碼。從一個遊標傳遞列名以選擇另一個遊標的語句
DECLARE
COL VARCHAR2 (200);
OUTRECORD VARCHAR2 (200);
CURSOR c1 IS
SELECT COLUMN_NAME
FROM all_tab_columns
WHERE table_name = 'COMPARE1';
CURSOR c2(col varchar(200)) IS--col is the column names from c1
(SELECT DISTINCT COL
FROM COMPARE1
MINUS
SELECT DISTINCT COL
FROM COMPARE2);
BEGIN
OPEN c1;
LOOP
FETCH c1 INTO COL;
DBMS_OUTPUT.put_line (COL);
OPEN c2(col);--col Is not passing to 2nd cursor
LOOP
FETCH c2 INTO OUTRECORD;--outrecord is empty is col is not passed to 2nd cursor
INSERT INTO RESULT
VALUES ('B001',
'COMPARE',
'2018',
COL,
OUTRECORD,--empy value
'NOT PRESENT IN 2017');
COMMIT;
END LOOP;
CLOSE c2;
END LOOP;
CLOSE c1;
END;
幫助我將值傳遞給c1.Thanks提前
哪個RDBMS是爲了這個?無論您使用的是MySQL,PostgreSQL,Oracle,SQL Server還是IBM DB2,或者甚至是其他軟件,它都會產生影響。請爲您的問題添加相關標籤! –
我們正在使用Oracle – mano