Oracle自动在多记录块中插入记录
Oracle automatically insert record in multirecord block
我的 table 看起来像这样:
+-------------------+
|Name |
+-------------------+
|Name1 |
|Name2 |
|Name3 |
|Name1Jr |
|Name2Jr |
|Name3Jr |
+-------------------+
我的多行块看起来像:
我想知道的是如何在插入姓名后插入与Jr同名的记录。比如我插入了Name2,它也会将Name2Jr插入到多行块中。像这样:
我试过 post 记录触发器:
insert tbl.name into name
from table tbl
where tbl.name = name||'Jr.'
注意:我需要从数据库中获取自动插入数据的值
这是一种选择。
- 创建数据库块
- 将其 "Navigation style" 属性 设置为 "Change record"
创建块级 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;
运行表格
我的 table 看起来像这样:
+-------------------+
|Name |
+-------------------+
|Name1 |
|Name2 |
|Name3 |
|Name1Jr |
|Name2Jr |
|Name3Jr |
+-------------------+
我的多行块看起来像:
我想知道的是如何在插入姓名后插入与Jr同名的记录。比如我插入了Name2,它也会将Name2Jr插入到多行块中。像这样:
我试过 post 记录触发器:
insert tbl.name into name
from table tbl
where tbl.name = name||'Jr.'
注意:我需要从数据库中获取自动插入数据的值
这是一种选择。
- 创建数据库块
- 将其 "Navigation style" 属性 设置为 "Change record"
创建块级
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;
运行表格