首页 > 解决方案 > oracle 报告词法参数

问题描述

我正在使用 oracle 报告,但“SELECT ALL”有问题这是我的查询

SELECT * FROM company A, seller B
WHERE a.id = b.id 
&(P)Company_id

在我使用的 oracle 报告中的 after 参数中

begin 
    if (:(V)Company_id is not null and :(V)Company_id<> '0')
       :(P)Company_id:= ' and a.id ='||:(V)Company_id;
    end if;
    return (true)`
end;

如果 id 是所有数字000123,则工作正常,但如果 id 像([L]00123)结果是显示所有数据。我的词法参数需要帮助。

标签: oracleoraclereports

解决方案


您发布的信息具有误导性。我已经使用 Oracle Reports多年了,但我从未见过您使用的语法。您编写的代码甚至无法编译;那么它是如何工作的(这就是你所声称的)?根本没有(V)something语法。

无论如何,从我的角度来看,你不需要一个词法参数而是一个简单的OR条件,例如

select *
from company a join seller b on b.id = a.id
where (a.id = :par_company_id or :par_company_id is null)
  • 它的第一部分,a.id = :par_company_id将返回 ID 等于您在参数表单中输入的值的行
  • 第二部分,or :par_company_id is null如果您将参数值留空,将返回所有行

推荐阅读