Oracle自动在multirecord块中插入记录

时间:2018-06-11 00:55:33

标签: oracle oracle11g oracleforms

我的表格如下:

+-------------------+
|Name               |
+-------------------+
|Name1              |
|Name2              |
|Name3              |
|Name1Jr            |
|Name2Jr            |
|Name3Jr            |
+-------------------+

我的多行块看起来像:

enter image description here

我想知道的是在插入名称后如何插入与Jr具有相同名称的记录。例如,我插入了Name2,它也会将Name2Jr插入到multirow块中。像这样:

enter image description here

我尝试了后记录触发器:

insert tbl.name into name
from table tbl
where tbl.name = name||'Jr.'

注意: 我需要从数据库中获取自动插入数据的值。

1 个答案:

答案 0 :(得分:1)

这是一个选项。

  • 创建数据库块
  • 设置其导航风格"属性"更改记录"
  • 创建块级WHEN-NEW-RECORD-INSTANCE触发器:

    if :system.trigger_record = 1 and :test.name is null then
       -- do nothing if it is the first record in a form
       null;
    else
       duplicate_record;
       if substr(:test.name, -2) = 'Jr' then
          -- you've duplicated a record which already has 'Jr' at the end - don't do it
          :test.name := null;
       else       
          -- concatenate 'Jr' to the duplicated record
          :test.name := :test.name || 'Jr';
       end if;      
    end if;  
    
  • 运行表单