Oracle APEX错误ORA-01460 ORA-02063
我正在使用以下代码创建一个经典报告(基于函数):Oracle APEX错误ORA-01460 ORA-02063,oracle,plsql,oracle-apex,Oracle,Plsql,Oracle Apex,我正在使用以下代码创建一个经典报告(基于函数): declare q long; begin -- The query with any conditions always applied q := 'select * from name_selection_atnd where 1 = 1'; -- If all items are null then kill query if :P500_FN is null and :P500_LN is null then
declare
q long;
begin
-- The query with any conditions always applied
q := 'select * from name_selection_atnd where 1 = 1';
-- If all items are null then kill query
if :P500_FN is null
and :P500_LN is null
then
q := q || ' and name_said = 0'; --will always return 0 rows
end if;
-- Append any optional conditions
if :P500_FN is not null then
q := q || ' and name_first_name = :P500_FN';
end if;
if :P500_LN is not null then
q := q || ' and name_last_name = :P500_LN';
end if;
return q;
end;
除了名字和姓氏之外,我的最终代码还需要包含更多要搜索的项目,但目前我只使用这两个参数进行测试。当我只填写一个名字时,搜索就起作用了。当我只填写姓氏时,它就起作用了。当我输入名字和姓氏时,我得到错误ORA-01460和ORA-02063
我可能做错了什么?您不需要动态SQL:
SELECT *
FROM name_selection_atnd
WHERE ( :P500_FN IS NULL OR name_first_name = :P500_FN )
AND ( :P500_LN IS NULL OR name_last_name = :P500_LN )
AND ( :P500_FN IS NOT NULL OR :P500_LN IS NOT NULL );
我可以看到您在
'
中使用了bind
变量,这在PLSQL块中永远不会被计算:
q := q || ' and name_first_name = :P500_FN';
这应该是这样的:
q := q || ' and name_first_name = '||:P500_FN;
您输入的是什么内容。为什么到处都使用绑定变量。在declare中仅使用一次即可将值从bind变量获取到局部变量。对这些变量进行比较。我正在键入一个字符串。你能给出完整的错误信息而不仅仅是代码吗?报告错误:ORA-01460:未执行或不合理的转换请求ORA-02063:JHS_ATND的前一行什么是
JHS_ATND
?太好了!但是现在如果我输入一个像“Jordan”这样的名字,我会得到这个错误ORA-00904:“Jordan”:无效identifier@JordanHolmer您需要将Jordan
作为字符串传递,因此传递时它必须位于'Jordan'
中。传递值时必须包含单引号(')。