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 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 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 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.
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.
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 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 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 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 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 ’事件。