简体   繁体   English

Oracle Apex 20.1 错误:处理验证时出错

[英]Oracle Apex 20.1 Error: Error processing validation

I am trying to create a validation for a page in an application on oracle apex.我正在尝试为 oracle 顶点上的应用程序中的页面创建验证。 Below is the pl/sql function body (returning boolean) I have:下面是我有的 pl/sql function 主体(返回布尔值):

declare v_equipid integer;
begin
        SELECT count(*) into v_equipid from equipment
        WHERE equipstatus = 'available' and equipID = :P3_EquipID;

    if v_equipid = 1 then
        return true;
    else
        return false;
    end if;
end; 

It is used to check whether the EquipID submitted has equipstatus = 'available'.用于检查提交的EquipID是否有equipstatus = 'available'。 After I run the application and submit the form, it gives the following error:在我运行应用程序并提交表单后,它给出了以下错误:

Error: Error processing validation.错误:处理验证时出错。

  • is_internal_error: true is_internal_error: 真
  • is_common_runtime_error: false is_common_runtime_error: false
  • apex_error_code: APEX.VALIDATION.UNHANDLED_ERROR apex_error_code:APEX.VALIDATION.UNHANDLED_ERROR
  • ora_sqlcode: -6502 ora_sqlcode:-6502
  • ora_sqlerrm: ORA-06502: PL/SQL: numeric or value error ORA-06512: at "APEX_200100.WWV_FLOW_VALIDATION", line 846 ORA-06512: at "APEX_200100.WWV_FLOW_VALIDATION", line 846 ora_sqlerrm:ORA-06502:PL/SQL:数字或值错误 ORA-06512:在“APEX_200100.WWV_FLOW_VALIDATION”,第 846 行 ORA-06512:在“APEX_200100.WWV_FLOW_VALIDATION”,第 846 行
  • error_backtrace: ORA-06512: at "APEX_200100.WWV_FLOW_VALIDATION", line 846 ORA-06512: at "APEX_200100.WWV_FLOW_VALIDATION", line 846 ORA-06512: at "APEX_200100.WWV_FLOW_VALIDATION", line 1029 error_backtrace:ORA-06512:在“APEX_200100.WWV_FLOW_VALIDATION”,第 846 行 ORA-06512:在“APEX_200100.WWV_FLOW_VALIDATION”,第 846 行 ORA-06512:在“APEX_200100.WWV_FLOW_VALIDATION”,第 1029 行

I don't know how to fix this and I would appreciate your help.我不知道如何解决这个问题,非常感谢您的帮助。 Thank you in advance!先感谢您!

Numeric or value error, eh?数值或数值错误,嗯?

This is what might be causing the problem:这可能是导致问题的原因:

and equipID = :P3_EquipID;

What is equipID 's datatype? equipID的数据类型是什么? If it is a NUMBER , try如果是NUMBER ,请尝试

and equipID = to_number(:P3_EquipID);

As that's not the case (as you commented), would this help?由于情况并非如此(正如您评论的那样),这有帮助吗?

declare 
  v_equipid number;
begin
  SELECT count(*) 
    into v_equipid 
    from equipment
    WHERE equipstatus = 'available' 
      and equipID = :P3_EquipID;

  return v_equipid = 1;
end; 

The key to developing in apex is debugging your own code.在 apex 中开发的关键是调试自己的代码。 That takes a bit of getting used to.这需要一点时间来适应。 Research on how to debug your apex app and instrument your pl/sql code, there is plenty of documentation available on the web.关于如何调试您的 apex 应用程序和检测您的 pl/sql 代码的研究,web 上有大量可用的文档。

You could just debug the validation by running that pl/sql in SQL workshop.您可以通过在 SQL 研讨会中运行该 pl/sql 来调试验证。 Replace your RETURN TRUE/FALSE statements with dbms_output.put_line('true/false') to get the result.dbms_output.put_line('true/false')替换您的RETURN TRUE/FALSE语句以获得结果。 Running it in sql workshop will give you the exact line number.在 sql 车间运行它会给你确切的行号。 ORA-06502 usually means that a variable or column of type NUMBER is assigned a value of datatype VARCHAR2 (or another datatype that cannot be casted back to a number). ORA-06502 通常意味着为 NUMBER 类型的变量或列分配了数据类型 VARCHAR2 的值(或其他不能转换回数字的数据类型)。

Make sure you remove the dbms_output statements again when you move the code back to apex.确保在将代码移回 apex 时再次删除 dbms_output 语句。

You could also debug your process in apex itself by using apex_debug, have a look at the documentation for a full overview of the functionality, something like this:您还可以使用 apex_debug 在 apex 本身中调试您的进程,查看文档以获取功能的完整概述,如下所示:

DECLARE
  v_equipid NUMBER; --integer is deprecated, should not be used
BEGIN
  -- put double quotes around the %0 to make any trailing/leading characters visible.
  apex_debug.info(
      p_message => 'Start of validation,  P3_EQUIPID = "%0"',
      p0        => :P3_EQUIPID);
  SELECT COUNT(*)
    INTO v_equipid
    FROM equipment
   WHERE equipstatus = 'available' AND
         equipid = :P3_EQUIPID;
  apex_debug.info(
      p_message => 'After SELECT INTO,  v_equipid = "%0"',
      p0        => v_equipid);
  IF v_equipid = 1 THEN
    RETURN true;
  ELSE
    RETURN false;
  END IF;
END;

Enable debug in the developer toolbar and investigate debug for your page.在开发人员工具栏中启用调试并调查您的页面的调试。 The messages you put in there should be available in the debug logs.您放入其中的消息应该在调试日志中可用。 The messages you put in the code after the error is thrown will not be visible since that code will not be executed.抛出错误后您在代码中输入的消息将不可见,因为该代码不会被执行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM