当我试图打开页面时,我收到错误“返回:8011 - SQL语句太长”。我们有大约数百万行。
在页面上,我们正在填充滚动,并在where语句中创建这样的东西
For &i = 1 To &rs.ActiveRowCount
&PARAM1 = &rs(&i).Record.SETID.Value;
&PARAM2 = &rs(&i).Record.VENDOR_ID.Value;
&strWhere = &strWhere | " OR ";
&strWhere = &strWhere | "(SETID = " | "'" |(&PARAM1) | "'" | " AND VENDOR_ID = " | "'" |(&PARAM2) | "'" | ")";
End-for;
进行滚动选择时是否有限制?
解释起来有点棘手,因为您需要更改的不仅仅是代码片段。
修改你的代码,使其更像这样:
&strWhere = ", PS_SOME_RECORD b where b.keyfield_1 = :1 and b.keyfield_2 = :2 ";
&strWhere = &strWhere | "and b.setid = a.setid ";
&strWhere = &strWhere | "and b.vendorid = a.vendorid";
相识又有差别:
&strWhere = " inner join PS_SOME_RECORD b on b.setid = a.setid and b.vendor_id = a.vendor_id ";
&strWhere = &strWhere | "and b.keyfield_1 = :1 and b.keyfield_2 = :2";
基本上:使用数据库而不是尝试构建1,000,000行SQL语句。
最终你想从数据库(假设VENDOR表)返回一些不同的东西:
select *
from ps_vendor a
inner join ps_your_rs_table b
on b.setid = a.setid
and b.vendor_id = a.vendor_id
where b.some_field = [your filter/predicates]
这是由于条件“IN”传递的值的长度。
由于IN(“”)中传递的数据值超出限制,因此会导致此错误。