0

我想知道我是否编写了代码,所以它产生了两个相同的 sql 语句,但是变量名不同的地方会被缓存为同一个语句吗?

例如,如果我有:

Select * from example where id in (:inarg0, inarg1);
Select * from example where id in(:inarg2, inarg3);

更新: 我做了一个函数,它将获取一个数据数组并将其转换为每次调用函数时递增的绑定变量。这很棒有sql注入。我只是希望通过缓存语句也能从中获得一些性能。位置绑定变量不是一个选项,因为该函数与其他可绑定变量(如

Select * from example where name = :name and expt = (:inarg0, inarg1) and date=:todaysDate and loc in (:inarg2, :inarg3, :inarg4)

如果函数要在同一个程序中再次运行,它看起来像这样:

Select * from example where name = :name and expt = (:inarg5, inarg6) and date=:todaysDate and loc in (:inarg7, :inarg8, :inarg9)
4

1 回答 1

0

它将被视为不同的查询 - 解析的查询不会被重用。要对其进行测试,请执行这两个查询并验证 v$sql 中的相应行。您正在做类似于 cursor_sharing=force 参数值的事情 - 除了 Oracle 在变量名方面做得更好 - 使它们更易于 SQL 重用。

于 2013-06-09T12:21:54.030 回答