0
取假設我有一個表conf
與主鍵PK
:複雜的光標
Conf
------------------
PK A B C
------------------
1 Y Y Y
2 Y Y
3 Y
------------------
我有另一個表溫度:
Temp
------------------
PK A B C
------------------
1 ab cd ef
1 null cd ef
2 cd pq
3 dn
------------------
我需要獲取列和PK的所有名稱來自conf
表,其值爲Y
,例如:
1 A B C
2 A C
3 A
這些值需要與temp
表格行進行比較,並檢查列中獲取的列的值是否爲null,如果是,則拋出錯誤。
例如,對於2 A C
,我們需要將具有2
的臨時表的A和C列與PK
進行比較。
我的問題是我怎麼能獲取以下紀錄光標:
1 A B C
2 A C
3 A
我沒有得到該優化的解決方案。可以通過將conf
表的所有列與temp
表進行比較來完成,但可以有多於15列。
算法的要點是:
fetch all column name from conf table having value 'Y'
loop
fetch all the columns from temp table with primary key from outer cursor
loop
On the basis of column name from outer cursor check the value of column
of temp table for its nullability
end loop;
end loop;