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;