Oracle Apex-动态操作错误:AJAX调用返回服务器错误ORA -20187

发布于 2025-02-07 10:14:53 字数 1273 浏览 2 评论 0原文

我有一个表格,一个输入项目必须是唯一的。 (这是主要键。)当我单击添加时,我会收到一个错误消息。没关系,但是当我设置项目的值时,我想在填写整个表单并单击“添加”按钮时获取此错误消息。

例如,我有一个带有country_id列的乡村桌。 country_id列必须是唯一的。

  1. 我创建了一个隐藏的页面项目:c_id_check

  2. 我创建了一个动态动作:

事件 - >更改

选择类型 - >项目

项目 - > p6_country_id

  1. 我创建了一个真正的动态动作。 执行服务器端代码 - > pl/sql
DECLARE pk_error   NUMBER;
   BEGIN
      SELECT 1 INTO pk_error
         FROM COUNTRY
         WHERE COUNTRY_ID = :P6_COUNTRY_ID;
     :P6_C_ID_CHECK := 'Y';
    
EXCEPTION
   WHEN others THEN
      :P6_C_ID_CHECK := 'N';
END;

项目要提交 - > :p6_country_id

项目返回 - > :p6_c_id_check,

因此,如果新的country_id已经exsist,则C_ID_CHECK值为y,否则N。

  1. 我创建了另一个真实的动态操作。动作 - >警报

客户端条件:

类型 - >项目=价值

项目 - > P6_C_ID_CHECK

值 - > y

因此,如果第一个动态操作将y值放在p6_c_id_check项目中,那么如果该值为y,则此动态操作会引起警报。

当我尝试时,我会收到此消息:

ajax调用返回的服务器错误ORA -20987:APEX-尝试在节目处理过程中将项目p6_country_id保存在会话状态。项目保护级别表示: 伴随“会话”校验和时,可能会设置项目。

没有校验和校验和通过的校验和适用于具有保护级别的物品“(没有提供校验和的项目)”。

注意:最终用户会收到另一个错误消息。 - 联系您的应用程序管理员。对于ajax_set_session_state。

怎么了?如果我尝试插入错误的数据,或者还有其他 /更简单的方法,这是立即通知的好方法吗?

I have a form and one input item must be unique. (It is primary key.) When I click to add, I get an error message. It is OK, but I want to get this error message when I set the item's value not when I filled the whole forms and click on the ADD button.

For example I have a COUNTRY table with a COUNTRY_ID column. The COUNTRY_ID column must be unique.

  1. I created a hidden page item: C_ID_CHECK

  2. I created a dynamic action:

Event --> change

Selection type --> Item

Item --> P6_COUNTRY_ID

  1. I created a true dynamic action.
    Execute Server-side Code --> pl/sql
DECLARE pk_error   NUMBER;
   BEGIN
      SELECT 1 INTO pk_error
         FROM COUNTRY
         WHERE COUNTRY_ID = :P6_COUNTRY_ID;
     :P6_C_ID_CHECK := 'Y';
    
EXCEPTION
   WHEN others THEN
      :P6_C_ID_CHECK := 'N';
END;

Items to submit --> :P6_COUNTRY_ID

Items to Return --> :P6_C_ID_CHECK

So if the new COUNTRY_ID already exsist, then C_ID_CHECK value is Y, otherwise N.

  1. I created another true dynamic action. Action --> Alert

Client-side Condition:

Type --> Item = Value

Item --> P6_C_ID_CHECK

Value --> Y

So if the first dynamic action put Y value to the P6_C_ID_CHECK item, then this dynamic action raise an alert if the value is Y.

When I tried it I got this message:

Ajax call returned server error ORA-20987: APEX - Attempt to save item P6_COUNTRY_ID in session state during show processing. Item protection level indicates:
Item may be set when accompanied by a "session" checksum.

No checksum was passed in or the checksum passed in would be suitable for an item with protection level "(No checksum was provided)".

Note: End users get a different error message. - Contact your application administrator. for ajax_set_session_state.

What could go wrong? Is this a good way to get immediate notification if I try to insert wrong data or is there any other / easier way?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

小镇女孩 2025-02-14 10:14:53

这不是处理顶点中主要键的正确方法。 始终让数据库使用触发器和序列处理主键,这是(1) - 这是旧方法或(2)使用身份列 - 这是更现代的方法。

然后,在您的应用程序中,让本机形式流程为您完成工作。将您的表单中的主要键项标记为“主键”,然后您就完成了。

在EMP/Dept样本数据上的示例应用程序中对此进行测试。创建一个类型交互式报告的新页面,然后检查“包含表单”。使用“ EMP”作为表。这将生成一个报告和表格,该报告既可以处理新记录的创建或更新现有记录。如果PK是唯一的,则永远不需要检查。

这是一个非常完整的 blog 来自Apex Dev团队解释了形式功能。

This is not the correct way of handling primary keys in apex. Always have the database handle your primary keys, either by (1) using a trigger and a sequence - this is the old way or (2) using an identity column - this is the more modern way.

Then in your application, let the native form processes do the work for you. Mark the primary key item in your form as "Primary Key" and you're done.

Test this out in a sample app on the emp/dept sample data. Create a new page of type Interactive Report and check "include form". Use "EMP" as the table. This will generate a report and form that handles both creation of new records or updating existing records. There never is a need for a check if the PK is unique.

Here is a very complete blog from the apex dev team explaining the form functionality.

我是有多爱你 2025-02-14 10:14:53

我同意Koen的观点,这不是一个好的设计。

但是要回答您的问题,错误消息说您已打开“项目保护”。编辑您的P6_C_ID_CHECK组件,并设置值保护为“否”。这应该使您可以通过动态动作进行更新。

参见这个类似的问题,and “隐藏”项目类型的文档

I agree with Koen that this is not a good design.

But to answer your question, the error message is saying that you have "item protection" turned on. Edit your P6_C_ID_CHECK component and set Value Protected to "No". That should allow you to update it from a Dynamic Action.

See this similar question, and the documentation for "hidden" item types.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文