【发布时间】:2010-03-25 10:35:21
【问题描述】:
我的过程中有两个游标,它们仅在它们加入的表名上有所不同。 使用的游标由传递给过程的参数确定
if (param = 'A') then
DECLARE CURSOR myCursor IS
SELECT x,y,z
FROM table1 a, table2 b
BEGIN
FOR aRecord in myCursor
LOOP
proc2(aRecord.x, aRecord.y, aRecord.z);
END LOOP;
COMMIT;
END;
elsif (param = 'B') then
DECLARE CURSOR myCursor IS
SELECT x,y,z
FROM table1 a, table3 b -- different table
BEGIN
FOR aRecord in myCursor
LOOP
proc2(aRecord.x, aRecord.y, aRecord.z);
END LOOP;
COMMIT;
END;
end if
我不想为了一张不同的表而重复代码。 有什么改进的建议吗?
提前致谢
【问题讨论】:
标签: stored-procedures plsql oracle10g