搜索表格 - 执行查询 - 当找到详细记录然后消息时

发布于 2025-02-13 14:20:48 字数 202 浏览 2 评论 0原文

我有一个搜索sales_orders/payment_details表格...

我正在通过Enter and Execute查询搜索记录,但是在某些情况下找不到详细记录,

例如:输入销售订单和执行付款记录,但尚未付款...

然后...然后我想提供消息(“找不到记录”)。.

请指导我触发器及其执行水平,

谢谢 javed

I have a search sales_orders/payment_details form ...

I am searching record through enter and execute query but in some cases detail record is not found

For Example: Enter Sales Order and Execute Payment record but there is no payment made yet...

then i would like to give message ('No record found')..

please guide me the trigger and its level of execution

Thanks
Javed

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

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

发布评论

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

评论(1

我喜欢麦丽素 2025-02-20 14:20:48

那是一种主详细信息。我建议您以这种方式创建它,并让表格担心默认数据处理(查询,插入,删除) - 使用数据块向导,它将竭尽所能,并创建数量的触发器,这些触发器将强制执行主尾关系。

完成后,一切都将只是工作 - 您不必编写一行代码。

由于我没有您的表格,我使用了Scott的Dept(Master)和EMP(详细信息)。如果您熟悉该模式,您会知道部门10、20和30中有一些员工,但是在部门40中没有人工作。

因此,您想在查询部门40时显示一些消息。在部门10上执行查询的输出端是输出的;右边是我们真正想要的(部门40,没有员工):

”在此处输入图像描述”

如何做?导航到对象导航器中的“程序单位”,并编辑query_master_details触发 - 它是数据块向导创建的那些对象之一。

编辑其代码并添加一些行,以检查是否存在细节行;如果没有,请显示一条消息(请参阅第20行):

PROCEDURE Query_Master_Details(rel_id Relation,detail VARCHAR2) IS
  oldmsg VARCHAR2(2);  -- Old Message Level Setting
  reldef VARCHAR2(5);  -- Relation Deferred Setting
BEGIN
  --
  -- Initialize Local Variable(s)
  --
  reldef := Get_Relation_Property(rel_id, DEFERRED_COORDINATION);
  oldmsg := :System.Message_Level;
  --
  -- If NOT Deferred, Goto detail and execute the query.
  --
  IF reldef = 'FALSE' THEN
    Go_Block(detail);
    Check_Package_Failure;
    :System.Message_Level := '10';
    Execute_Query;
    :System.Message_Level := oldmsg;
    
    -- I added this 4 lines:                            --> here
    if :employees.empno is null then
       message('No employees in that department');
       message('No employees in that department');
    end if; 
    -- End of lines added by LF

  ELSE
    --
    -- Relation is deferred, mark the detail block as un-coordinated
    --
    Set_Block_Property(detail, COORDINATION_STATUS, NON_COORDINATED);
  END IF;

EXCEPTION
    WHEN Form_Trigger_Failure THEN
      :System.Message_Level := oldmsg;
      RAISE;
END Query_Master_Details;

为简单起见,我使用了两个连续的消息调用,然后像警报一样起作用(否则,该消息将显示在状态行中在窗户的底部)。如果需要,可以使用“真实”警报;我把它留给你。

That's a master-detail form. I suggest you create it that way and let Forms worry about default data handling (querying, inserting, deleting) - use Data Block Wizard, it'll do everything right and create number of triggers which will enforce the master-detail relationship.

Once you're done, everything will just work - you don't have to write a single line of code.

As I don't have your tables, I used Scott's dept (master) and emp (detail). If you're familiar with that schema, you know that there are some employees in departments 10, 20 and 30, but nobody works in department 40.

Therefore, you'd want to display some message when you query department 40. On the left hand side is output for executing query on department 10; on the right is what we actually want (department 40, no employees there):

enter image description here

How to do that? Navigate to "Program units" in Object Navigator and edit the QUERY_MASTER_DETAILS trigger - it is one of those objects created by the Data Block Wizard.

Edit its code and add a few lines which will check whether detail rows exist; if not, display a message (see line #20):

PROCEDURE Query_Master_Details(rel_id Relation,detail VARCHAR2) IS
  oldmsg VARCHAR2(2);  -- Old Message Level Setting
  reldef VARCHAR2(5);  -- Relation Deferred Setting
BEGIN
  --
  -- Initialize Local Variable(s)
  --
  reldef := Get_Relation_Property(rel_id, DEFERRED_COORDINATION);
  oldmsg := :System.Message_Level;
  --
  -- If NOT Deferred, Goto detail and execute the query.
  --
  IF reldef = 'FALSE' THEN
    Go_Block(detail);
    Check_Package_Failure;
    :System.Message_Level := '10';
    Execute_Query;
    :System.Message_Level := oldmsg;
    
    -- I added this 4 lines:                            --> here
    if :employees.empno is null then
       message('No employees in that department');
       message('No employees in that department');
    end if; 
    -- End of lines added by LF

  ELSE
    --
    -- Relation is deferred, mark the detail block as un-coordinated
    --
    Set_Block_Property(detail, COORDINATION_STATUS, NON_COORDINATED);
  END IF;

EXCEPTION
    WHEN Form_Trigger_Failure THEN
      :System.Message_Level := oldmsg;
      RAISE;
END Query_Master_Details;

For simplicity, I used two consecutive message calls which then act as if it were an alert (otherwise, that message would be displayed in the status line at the bottom of the window). If you want, you can use "real" alert; I'll leave it to you.

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