Oracle Form触发器执行顺序是怎样的

77次阅读
没有评论

共计 13971 个字符,预计需要花费 35 分钟才能阅读完成。

这篇文章主要讲解了“Oracle Form 触发器执行顺序是怎样的”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着丸趣 TV 小编的思路慢慢深入,一起来研究和学习“Oracle Form 触发器执行顺序是怎样的”吧!

Form 的 Trigger 的优先级是从 item,到 block,到 form 级别,如果另外设置 Execution
Hierarch 属性(override,before,after),则按照设置后的顺序执行。如果是 override 的话,则执行完这个级别的触发器,就不往上执行了,before 就是执行完这个级别的触发器后,如果上一个级别也有这个触发器的话,继续去执行,after 就是先去执行上一个级别的触发器,然后再回来执行。感觉触发器比较难理解的还是每一种触发器触发的时间,和在开发中怎么使用。目前了解的就是 pre-…,when-new-…-instance,when-…-validate,post-query 和几个 on-…触发器

触发器执行顺序:

1.当打开 FORM 时:

(1)PRE-FORM

(2)PRE-BLOCK(BLOCK 级)

(3)WHEN-NEW-FORM-INSTANCE

(4)WHEN-NEW-BLOCK-INSTANCE

(5)WHEN-NEW-RECORD-INSTANCE

(6)WHEN-NEW-ITEM-INSTANCE

2.当填写一行记录完成后,光标移动到下一条记录的时候:

(1)WHEN-VALIDATE-RECORD
(只将填写的记录与数据库中已存在的记录作唯一性的验证, 如果只是页面上的数据重复而数据库中没有与其重复的值则不会报错.)

(2)WHEN-NEW-RECORD-INSTANCE

(3)WHEN-NEW-ITEM-INSTANCE

3.当点击“保存”时

(1)WHEN-VALIDATE-RECORD
(将页面上的所有数据提交到数据库,若页面上有重复的数据,则提交第一次时成功但只是将数据先写到数据库中一类似临时表的地方,在提交第二条重复记录的时候报错,执行事务回滚,原来执行成功的指令也将被撤消)

(2)PRE-INSERT

(3)ON-INSERT

(4)POST-INSERT

(5)POST-FORMS-COMMIT

(6)PRE-BLOCK(BLOCK 级)

(7)KEY-COMMIT

(8)WHEN-NEW-ITEM-INSTANCE

4.当光标移动到当前数据块中已经显示的行上时:

(1)WHEN-REMOVE-RECORD

(2)WHEN-NEW-RECORD-INSTANCE

(3)WHEN-NEW-ITEM-INSTANCE

当在该行上的不同 ITEM 移动时:

(4)WHEN-NEW-ITEM-INSTANCE

5.当要进行修改时(在记录中的某个项上进行了修改时):

(1)ON-LOCK

6.在修改完成后进行保存时:

(1)WHEN-VALIDATE-RECORD

(2)PRE-UPDATE

(3)ON-UPDATE

(4)POST-FORMS-COMMIT

(5)PRE-BLOCK(BLOCK 级)

(6)KEY-COMMIT

(7)WHEN-NEW-ITEM-INSTANCE

7.删除一条记录时:

(1)ON-LOCK

(2)WHEN-REMOVE-RECORD

(3)KEY-DELREC

(4)WHEN-NEW-RECORD-INSTANCE

(5)WHEN-NEW-ITEM-INSTANCE

8.F11 查询过程:

(1)WHEN-CLEAR-BLOCK

(2)WHEN-NEW-RECORD-INSTANCE

(3)WHEN-NEW-ITEM-INSTANCE

在输入查询条件后点 CTRL+F11:

(4)PRE-QUERY

(5)WHEN-CLEAR-BLOCK

(6)POST-QUERY

(7)WHEN-NEW-RECORD-INSTANCE

(8)WHEN-NEW-ITEM-INSTANCE

9.CRRL+F11:

(1)WHEN-CLEAR-BLOCK

(2)PRE-QUERY

(3)WHEN-CLEAR-BLOCK

(4)POST-QUERY(每查一条记录,触发一次)

(5)WHEN-NEW-RECORD-INSTANCE

(6)WHEN-NEW-ITEM-INSTANCE

10.从查询状态(F11)转为输入状态(F4)时:

(1)WHEN-CLEAR-BLOCK

(2)KEY-EXIT

(3)WHEN-NEW-RECORD-INSTANCE

(4)WHEN-NEW-ITEM-INSTANCE

11.手电筒查询过程:

(1)QUERY_FIND(BLOCK 级)

输入查询条件后,点击“查询”按钮:

(2)WHEN-CLEAR-BLOCK

(3)PRE-QUERY

(4)WHEN-CLEAR-BLOCK

(5)POST-QUERY

(6)WHEN-NEW-RECORD-INSTANCE

(7)WHEN-NEW-ITEM-INSTANCE

12.点击“New”时:

(1)WHEN-NEW-RECORD-INSTANCE

(2)WHEN-NEW-ITEM-INSTANCE

13.点击“EditField”时:

(1)KEY-EDIT

14.点击“WindowHelp”时:

(1)KEY-HELP

15.点击“ClearRecord”时:

(1)WHEN-REMOVE-RECORD

(2)POST-QUERY

(3)WHEN-NEW-RECORD-INSTANCE

(4)WHEN-NEW-ITEM-INSTANCE

16.点击 F4 关闭时:

(1)KEY-EXIT

(2)POST-FORM

17.点击“CloseForm”按钮关闭时:

(1)KEY-EXIT

(2)POST-FORM

18.点击“Translations”按钮时:

(1)TRANSLATIONS

19.点击小叉号关闭时:

(1)WHEN-WINDOW-CLOSED

(2)CLOSE-WINDOW

(3)KEY-EXIT

(4)POST-FORM

20.选中 LOV 列表:

(1)KEY-LISTVAL

(2)WHEN-NEW-ITEM-INSTANCE

21.选中记录前面的小条时:

(1)WHEN-NEW-RECORD-INSTANCE

(2)WHEN-NEW-ITEM-INSTANCE(数据项级)

(3)WHEN-NEW-ITEM-INSTANCE

22.光标上下移动时:

(1)WHEN-NEW-RECORD-INSTANCE

(2)WHEN-NEW-ITEM-INSTANCE

Tag 标签:
Oracle Form Builder 触发器执行顺序

Triggers in Oracle Forms

Triggers are blocks of PL/SQL code that
are written to perform tasks when a specific event occurs within an
application. In effect, an Oracle Forms trigger is an event-handler
written in PL/SQL to augment (or occasionally replace)
the default processing behavior. Every trigger has a name, and contains
one or more PL/SQL statements. A trigger encapsulates PL/SQL code so
that it can be associated with an event and executed and maintained as a
distinct object.

Block Processing Triggers:

Block processing triggers fire in response to events related to record management in a block.

When-Create-Record
Perform an action whenever Oracle Forms attempts to create a new record in a block.

When-Clear-Block
Perform an action whenever Oracle Forms flushes the current block; that is, removes all records from the block.

When-Database-Record
Perform
an action whenever Oracle Forms changes a record’s status to Insert or
Update, thus indicating that the record should be processed by the next
COMMIT_FORM operation.

Interface Event Triggers:

Interface event triggers fire in
response to events that occur in the form interface. Some of these
triggers, such as When-Button-Pressed, fire only in response to operator
input or manipulation. Others, like When-Window-Activated,
can fire in response to both operator input and programmatic control.

When-Button-Pressed
Initiate an action when an operator selects a button, either with the mouse or through keyboard selection.

When-Checkbox-Changed
Initiate an action when the operator toggles the state of a check box, either with the mouse or through keyboard selection.

When-Image-Activated
Initiate an action whenever the operator double-clicks an image item.

When-Image-Pressed
Initiate an action whenever an operator clicks on an image item.

When-Radio-Changed
Initiate an action when an operator changes the current radio button selected in a radio group item.

When-Window-Activated
Initiate an action whenever an operator or the application activates a window.

When-Window-Closed
Initiate an action whenever an operator closes a window with the window manager’s Close command.

When-Window-Deactivated
Initiate an action whenever a window is deactivated as a result of another window becoming the active window.

Master/Detail Triggers:

Oracle Forms generates master/detail
triggers automatically when a master/detail relation is defined between
blocks. The default master/detail triggers enforce coordination between
records in a detail block and the master record
in a master block. Unless developing custom block-coordination schemes,
you do not need to define these triggers.

On-Check-Delete-Master
Fires when Oracle Forms attempts to delete a record in a block that is a master block in a master/detail relation.

On-Clear-Details
Fires when Oracle Forms needs to clear records in a block that is a
detail block in a master/detail relation because those records no longer
correspond to the current record in the master block.

On-Populate-Details
Fires when Oracle Forms needs to fetch records into a block that is the
detail block in a master/detail relation so that detail records are
synchronized with the current record in the master
block.

Message-Handling Triggers:

Oracle Forms automatically issues
appropriate error and informational messages in response to runtime
events. Message handling triggers fire in response to these default
messaging events.

On-Error
Replace a default error message with a custom error message, or to trap and recover from an error.

On-Message
To trap and respond to a message; for example, to replace a default message issued by Oracle Forms with a custom message.

Validation Triggers:

Validation triggers fire when Oracle
Forms validates data in an item or record. Oracle Forms performs
validation checks during navigation that occurs in response to operator
input, programmatic control, or default processing,
such as a Commit operation.

When-Validate-Item

When-Validate-Record

Navigational Triggers:

Navigational triggers fire in response
to navigational events. Navigational triggers can be further sub-divided
into two categories: Pre- and Post- triggers, and When-New-Instance
triggers. Pre- and Post- Triggers fire as Oracle
Forms navigates internally through different levels of the object
hierarchy. When-New-Instance-Triggers fire at the end of a navigational
sequence that places the input focus on a different item.

Pre-Form Perform an action just before Oracle Forms navigates to the form from“outside”the form, such as at form startup.

Pre-Block
Perform an action before Oracle Forms navigates to the block level from the form level.

Pre-Record
Perform an action before Oracle Forms navigates to the record level from the block level.

Pre-Text-Item
Perform an action before Oracle Forms navigates to a text item from the record level.

Post-Text-Item
Manipulate an item when Oracle Forms leaves a text item and navigates to the record level.

Post-Record
Manipulate a record when Oracle Forms leaves a record and navigates to the block level.

Post-Block
Manipulate the current record when Oracle Forms leaves a block and navigates to the form level.

Post-Form
Perform an action before Oracle Forms navigates to“outside”the form, such as when exiting the form.

When-New-Form-Instance Perform an action at form start-up. (Occurs after the Pre-Form trigger fires).

When-New-Block-Instance
Perform an action immediately after the input focus moves to an item in
a block other than the block that previously had input focus.

When-New-Record-Instance
Perform an action immediately after the input focus moves to an item in a different record.

When-New-Item-Instance
Perform an action immediately after the input focus moves to a different item. 

Transactional Triggers:

Transactional triggers fire in response to a wide variety of events that occur as a form interacts with the data source.

On-Delete

On-Insert

On-Update

On-Logon

On-Logout

Post-Database-Commit

Post-Delete

Post-Insert

Post-Update

Pre-Commit

Pre-Delete

Pre-Insert

Pre-Update

Query-Time Triggers:

Query-time triggers fire just before and just after the operator or the application executes a query in a block.

Pre-Query Validate
the current query criteria or provide additional query criteria
programmatically, just before sending the SELECT statement to the
database.

Post-Query
Perform an action after fetching a record, such as looking up values in
other tables based on a value in the current record. Fires once for
each record fetched into the block.

打开,关闭,创建,更新记录的 trigger 次序
PRE-……
在进入一个 form,或是导航到一个新的 block 时触发,PRE-……系列的触发器一般是在 WHEN-NEW-……-INSTANCE 系列之前,它们如果失败了的话,就不能成功导航到下一个对象了,只能留在当前的位置。在这些触发器里可以设置一些判断条件来限制是否可以导航到新的位置。

WHEN-NEW-……-INSTANCE
这一类的 trigger 都是当鼠标光标每次落到一个新的 block,record,item 上时触发的,而且就算失败了,也不会发生什么错误。但是 when-new-form-instance,只有当 form 启动时,光标导航到第一个导航块的第一个导航 item 时触发,如果一个应用有多个 form,当光标在各个 form 之间转换时,并不会触发它。

POST-TEXT-ITEM 和 WHEN-VALIDATE-ITEM
Post-text-item 的触发点:当输入的光标从一个 Text-Item
转到其它 item,可以用它来改变 item 的值,而 when-Validate-item 虽然也是在离开前触发,但是作用不同,Post-Text-Item 本身是没有验证的,when-Validate-item 可以用来补充一些验证(除了 form 本身的验证),但是当 form 验证成功以后,会把 item 标志为‘valid’, 而不会再去验证了,如果这时我们再去修改它的值,那么就有可能会把无效的值导入到数据库。在创建和更新一条记录时,先触发 when-Validate-item,再触发 Post-Text-Item,然后是 when-Validate-record。
POST-……系列的都是离开当前的 block,record,item 时触发的

WHEN-WINDOW-ACTIVATED
做原材料属性修改平台时,第一次使用这个触发器,用来从另一个 window 返回时,刷新当前 window,代码写在了这个触发器里。使用之前用 fnd_message.debug 试验了一下,打开窗口后不停的弹出 message。只要这个窗口在活动期间就会不停的执行这个触发起里面的代码,所以执行的代码应该用 if 条件限制一下。

Form 的 Trigger 的优先级是从 item,到 block,到 form 级别,如果另外设置 Execution
Hierarch 属性(override,before,after),则按照设置后的顺序执行。如果是 override 的话,则执行完这个级别的触发器,就不往上执行了,before 就是执行完这个级别的触发器后,如果上一个级别也有这个触发器的话,继续去执行,after 就是先去执行上一个级别的触发器,然后再回来执行。感觉触发器比较难理解的还是每一种触发器触发的时间,和在开发中怎么使用。目前了解的就是 pre-…,when-new-…-instance,when-…-validate,post-query 和几个 on-…触发器

验证代码写在 WHEN-VALIDATE-RECORD 和 PRE-INSERT 的不同
验证代码写在 WHEN-VALIDATE-RECORD 和 PRE-INSERT 的不同
1、写在 WHEN-VALIDATE-RECORD,可以及时地提示错误信息,如果验证时要和后台数据库关联的话,那么要写在 PRE-INSERT,因为 PRE-INSERT,ON-INSERT 都是一条一条记录执行的,这样批量录入时,每一条记录的验证都可以取到最新的数据库记录。
2、批量录入时,有一条的 PRE-INSERT 不成功,则所有记录都不能保存成功

Post-Query 和 When-New-Record-Instance 关系
Post-Query 和 When-New-Record-Instance
假定数据库中有 100 条记录,块设置显示行数为 10,那么当光标在显示出来的记录间移动时,只触发 When-New-Record-Instance,不触发 Post-Query。当光标移到第十一条记录时,触发 Post-Query

不可见 item 的 when-validate-item 使用
问题:如果一个 item 是不可见的,那么改变它的值,还会触发 when-validate-item 吗?
结果:会触发,但不是在改变它的值后触发,而是在光标移到另一个 block 时。关闭窗口时也触发了。
测试:设 block1 的 item1 为不可见,在 item2 的 when-validate-item 给 tem1 赋值,运行时,改变 item2 的值后,在 block1 的各 item 间移动光标都没有触发 item1 的 when-validate-item,直到光标离开这个 block,或关闭窗口时才触发。

ACCEPT Trigger 讲解
ACCEPT  APP_STANDARD.EVENT(‘ACCEPT’); 这个触发器处理菜单或工具条上调用 Save and Proceed
(保存并继续)动作。它执行保存,并移动到指定当作第一个导航块的块上。 
替换这个触发器中的代码,或创建块级触发器并把执行类型指定为‘Override’

FOLDER_RETURN_ACTION
FOLDER_RETURN_ACTION
  这个触发器允许指定客户华的文件夹事件
  用需要的处理文件夹动作的代码替换

KEY_DUPREC
APP_STANDARD.EVENT(‘KEY-DUPREC’);
  这个触发器禁用了 Oracle 表单默认的重复记录的功能

KEY-CLRFRM
KEY-CLRFRM
  APP_STANDARD.EVENT(‘KEY-CLRFRM’);
  这个触发器在试图清空 form 前验证记录
  在原来的代码后添加附加的代码,通常你你应添加 GO_BLOCK 如果 form 中存在多个的区域,使用 GO_BLOCK 在调用清空 from 操作后重新填充控制菜单

KEY_MENU
KEY_MENU
  APP_STANDARD.EVENT(‘KEY-MENU’);
  这个触发器禁用了 Oracle froms 的 Block Menu 命令
  为了启用从特定的块对替代的块通过键盘操作,那么编写块级 KEY_MENU 并且设定执行类型为’Override’这个触发器会打开一个与弹出式菜单相同的 LOV

KEY_LISTVAL
KEY_LISTVAL
  APP_STANDARD.EVENT(‘KEY-LISTVAL’);
  这个触发器执行弹性域操作或引用 LOV
  创建块或项级触发器并设置执行类型为‘Override’,可以使用日历或动态执行弹性域

ON-ERROR
ON-ERROR
  APP_STANDARD.EVENT(‘ON-ERROR’);
这个触发器处理服务器或客户端的所有的错误,使用消息字典调用。
为了捕获处理指定的错误,在调用 APP_STANDARD 前检查指定的错误 declare

original_mess varchar2(80);

begin

IF MESSAGE_CODE = your message number THEN

original_mess := MESSAGE_TYPE||’–’||

to_char(MESSAGE_CODE)||’:’||MESSAGE_TEXT;

––– your code handling the error goes here

message(original_mess);

ELSE

APP_STANDARD.EVENT(’ON_ERROR’);

END IF

end;

POST-FORM
POST-FORM.
  APP_STANDARD.EVENT(‘POST-FORM’);
这个触发器是预留为以后使用
添加附加的代码在原有代码之后。

PRE-FORM
PRE-FORM
FND_STANDARD.FORM_INFO(’$Revision: Number $’,
’Form. Name’,
’Application Shortname’,
’$Date: YY/MM/DD HH24:MI:SS $’,
’$Author: developer name $’);
APP_STANDARD.EVENT(’PRE–FORM’);
APP_WINDOW.SET_WINDOW_POSITION(’BLOCKNAME’,
’FIRST_WINDOW’);
这个触发器初始化 Oracle 应用的内部值和菜单。在这里输入的值将在 Oracle 应用程序菜单‘Help About Oracle Applications’中看到。
你必须编辑应用程序的简称,应用的简称控制当用户选择‘help’按钮后哪个应用的在线帮助文档将被调用。如果你将应用的简称设置为 FND,你的用户将会看不到任何帮助因为 Oracle 应用程序将不能建立可用的帮助目标。
Form 的名称是用户 form 名称(form 标题)。
Oracle 公司使用源控制系统,它可以自动更新以“$”开头的值,如果你不使用这个源控制系统你可以按你的开发信息编辑这些值。
你必须编辑 APP_WINDOW 中的 BLOCKNAME 为你自己的 block. 不要编辑 FIRST_WINDOW

QUERY_FIND
QUERY_FIND
APP_STANDARD.EVENT(‘QUERY_FIND’);
这个触发器将设置显示字符串’Query Find is not available’
在这个触发器中替代代码,当你创建窗口或 Row_LOV 在你的 form 中时创建块级触发器并设置执行类型为‘Override’

WHEN-NEW-FORM-INSTANCE
WHEN-NEW-FORM-INSTANCE
FDRCSID(’$Header: … $’);
APP_STANDARD.EVENT(’WHEN–NEW–FORM–INSTANCE’);
–– app_folder.define_folder_block(’template test’,
’folder_block’,’prompt_block’,’stacked_canvas’,
’window’,’disabled functions’);
–app_folder.event(’VERIFY’);
调用 APP_STANDARD.EVENT
是为了在 query-only 模式下调用 FND_FUNCTION.EXECUTE, 调用 FNDRCSID 是为了 Oracle
应用程序的源控制系统(source control system).APP_FOLDER
只为了 Oracle 应用程序内部调用。客户化 form 不需要 FDRCSID 或 APP_FOLDER 调用,但是如果将它们留在触发器中也没有影响。
在现有的代码前添加附加代码。

WHEN-NEW-RECORD-INSTANCE
WHEN-NEW-RECORD-INSTANCE
APP_STANDARD.EVENT(‘WHEN-NEW-RECORD-INSTANCE’);
这个触发器管理 Oracle 应用程序菜单和工具栏
创建块级触发器并设置执行类型为‘Before’

WHEN-NEW-ITEM-INSTANCE
WHEN-NEW-ITEM-INSTANCE
APP_STANDARD.EVENT(‘WHEN-NEW-ITEM-INSTANCE’);
这个触发器管理 Oracle 应用程序的菜单和工具栏
如果你添加弹性域方法调用,你应该添加它在 APP_STANDARD.EVENT 调用前调用,通常,你不应该添加任何代码在这个触发器中,这样的代码将会影响你表单的速度并且影响每一个项

Oracle EBS Form. 中,不能修改的 Trigger
Oracle 应用程序不支持修改 form 级的触发器
CLOSE_THIS_WINDOW
从菜单 Action- Close 调用触发器 APP_CUSTOM.CLOSE_WINDOW。
CLOSE_WINDOW
APP_CUSTOM.CLOSE_WINDOW(:SYSTEM.EVENT_WINDOW);
这个出发其处理所有关闭窗口的事件。编写处理关闭窗口的事件必须写在 APP_CUSTOM.CLOSE_WINDOW 包中
EXPORT
App_standard.event(‘EXPORT’);
这个触发器是“Action,Export”菜单中的选择。
FOLDER_ACTION
App_folder.event(:global.folder_action);
KEY-COMMIT
App_standard.event(‘KEY-COMMIT’);
这个触发器处理正常的提交或 form 调用
KEY-EDIT
App_standard.event(‘KEY-EDIT’);
这个触发器处理弹性域或日历,编辑器操作。
KEY-EXIT
App_standard.event(‘KEY-EXIT’);
这个触发器处理关闭事件和退出 enter-query 状态
KEY-HELP
App_standard.event(‘KEY-HELP’);
这个触发器调用窗口的帮助系统。
LASTRECORD
APP_STANDARD.EVENT(‘LASTRECORD’);
这个触发器处理菜单(Go – LAST RECORD)事件
MENU_TO_APPCORE
App_standard.event(:global.menu_to_appcore);
这个触发器支持 Special 菜单
STANDARD_ATTACHMENTS
Atchmt_api.invoke;
这个触发器处理附件菜单或工具按钮的调用
WHEN-WINDOW-CLOSE
Execute_trigger(‘CLOSE_WINDOW’);
这个触发器集中了 form 的关闭事件
WHEN-FORM-NAVIGATE
你不能修改这个触发器,它包含了标准的行为,当最小化的表单被导航到的时候正常化这个表单。
ZOOM
Appcore_custom.event(‘ZOOM’);
这个触发器处理菜单或工具条按钮’Action,Zoom’事件。

感谢各位的阅读,以上就是“Oracle Form 触发器执行顺序是怎样的”的内容了,经过本文的学习后,相信大家对 Oracle Form 触发器执行顺序是怎样的这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是丸趣 TV,丸趣 TV 小编将为大家推送更多相关知识点的文章,欢迎关注!

正文完
 
丸趣
版权声明:本站原创文章,由 丸趣 2023-07-20发表,共计13971字。
转载说明:除特殊说明外本站除技术相关以外文章皆由网络搜集发布,转载请注明出处。
评论(没有评论)