【发布时间】:2012-04-12 09:36:02
【问题描述】:
我有一个参数化(动态)查询,我想在 oracle 过程中重用(如果可能的话,甚至在 oracle 包中),如下所示:
cursor q (p1 integer, p2 integer, p3 ...) as
select .... from .... where col1 = p1 and col2 = p2 and ....
稍后在后续查询中执行类似的操作
select ...
from t1, t2, ..., q (a, b, c)
where q.c1 = t1.tc1
and q.c2 = t2.tc2
....
select ...
from n1, n2, ..., q (a, b, c)
where q.c1 = n1.tc1
and q.c2 = n2.tc2
....
如果查询是静态的,我使用了 VIEWS 但它不是.. 除了填充和使用大量额外的对象之外,还有其他更简单的方法吗?
【问题讨论】:
-
我实际上想重用代码而不是重用结果(但如果可能的话重用结果会更好)
-
其实查询不是那么动态的,它没有变化,只有参数是
标签: sql oracle plsql reusability