Oracle 表单生成器,pl/sql

Oracle form builder , pl/sql

我是 Oracle Forms 的新手,非常感谢您的帮助!

我的 Oracle Forms Builder 中有两个多记录块。我们将它们命名为 block1block2。 这些块具有相同的三列 - SequenceNameDate.

我的目标是 - 在按下 'Update' 按钮后,我需要根据 block1 的变化更新 block2

代码应该比较两个块。如果名称或日期在 block1 中更改(Sequence 无法更改),则在 block2 中更新它。

如果 block1 中的记录完全消失,那么 不要 更改 block2 中的任何内容,直接去到下一条记录。

如果可行,请告诉我。

谢谢!

这是一个嵌套循环选项。

因为我没有你的 table(并且不想创建),我正在使用 Scott 的 DEPT table(第一个块的来源, Dept 1) 及其副本创建为 create table dept2 as select * From dept(这是第二个块的来源,Dept 2)。

这是布局;屏幕截图是在我按下 "Update" 按钮后截取的:

  • 我查询了两个区块
  • 然后我更新了第一个块:
    • 对于 deptno = 10,我将 dname 设置为 xxx
    • 对于 deptnon = 30,我将 loc 设置为 yyy
  • 然后我按下了将 xxx 和 yyy 复制到第二个块的按钮

执行此操作的代码如下所示;阅读代码中的注释。

-- go to the second block; navigate to the first record
go_block('dept2');
first_record;

loop
  -- this variable contains current cursor position. It will be used later
  -- with GO_RECORD. Why? To avoid indefinite loop
  :global.rec := :system.cursor_record;

  -- go to the first block and - in a loop - scroll through all its rows
  go_block('dept1'); 
  first_record;
  loop
    -- if DEPTNO columns match, then update second block's values to first block's.
    -- I don't really care whether they are different or not - I perform update unconditionally
    if :dept2.deptno = :dept1.deptno then
         :dept2.dname := :dept1.dname;
         :dept2.loc   := :dept1.loc;
    end if;
    exit when :system.last_record = 'TRUE';
    next_record;
  end loop;

  -- I've done scrolling through the first block. Go to the next row in the second block
  go_block('dept2');
  go_record(:global.rec);
  exit when :system.last_record = 'TRUE';
  next_record;
end loop;