博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Oracle Form 触发器执行顺序
阅读量:5793 次
发布时间:2019-06-18

本文共 15103 字,大约阅读时间需要 50 分钟。

1.    

2.    

3.    

4.    

5.    

6.    

7.    

8.    

9.    

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

 

触发器执行顺序:

1.当打开FORM时:

1PRE-FORM

2PRE-BLOCKBLOCK级)

3WHEN-NEW-FORM-INSTANCE

4WHEN-NEW-BLOCK-INSTANCE

5WHEN-NEW-RECORD-INSTANCE

6WHEN-NEW-ITEM-INSTANCE

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

1WHEN-VALIDATE-RECORD

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

2WHEN-NEW-RECORD-INSTANCE

3WHEN-NEW-ITEM-INSTANCE

3.当点击保存

1WHEN-VALIDATE-RECORD

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

2PRE-INSERT

3ON-INSERT

4POST-INSERT

5POST-FORMS-COMMIT

6PRE-BLOCKBLOCK级)

7KEY-COMMIT

8WHEN-NEW-ITEM-INSTANCE

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

1WHEN-REMOVE-RECORD

2WHEN-NEW-RECORD-INSTANCE

3WHEN-NEW-ITEM-INSTANCE

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

4WHEN-NEW-ITEM-INSTANCE

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

1ON-LOCK

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

1WHEN-VALIDATE-RECORD

2PRE-UPDATE

3ON-UPDATE

4POST-FORMS-COMMIT

5PRE-BLOCKBLOCK级)

6KEY-COMMIT

7WHEN-NEW-ITEM-INSTANCE

7.删除一条记录时:

1ON-LOCK

2WHEN-REMOVE-RECORD

3KEY-DELREC

4WHEN-NEW-RECORD-INSTANCE

5WHEN-NEW-ITEM-INSTANCE

8F11查询过程:

1WHEN-CLEAR-BLOCK

2WHEN-NEW-RECORD-INSTANCE

3WHEN-NEW-ITEM-INSTANCE

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

4PRE-QUERY

5WHEN-CLEAR-BLOCK

6POST-QUERY

7WHEN-NEW-RECORD-INSTANCE

8WHEN-NEW-ITEM-INSTANCE

9CRRL+F11

1WHEN-CLEAR-BLOCK

2PRE-QUERY

3WHEN-CLEAR-BLOCK

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

5WHEN-NEW-RECORD-INSTANCE

6WHEN-NEW-ITEM-INSTANCE

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

1WHEN-CLEAR-BLOCK

2KEY-EXIT

3WHEN-NEW-RECORD-INSTANCE

4WHEN-NEW-ITEM-INSTANCE

11.手电筒查询过程:

1QUERY_FINDBLOCK级)

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

2WHEN-CLEAR-BLOCK

3PRE-QUERY

4WHEN-CLEAR-BLOCK

5POST-QUERY

6WHEN-NEW-RECORD-INSTANCE

7WHEN-NEW-ITEM-INSTANCE

12.点击“New”时:

1WHEN-NEW-RECORD-INSTANCE

2WHEN-NEW-ITEM-INSTANCE

13.点击“EditField”时:

1KEY-EDIT

14.点击“WindowHelp”时:

1KEY-HELP

15.点击“ClearRecord”时:

1WHEN-REMOVE-RECORD

2POST-QUERY

3WHEN-NEW-RECORD-INSTANCE

4WHEN-NEW-ITEM-INSTANCE

16.点击F4关闭时:

1KEY-EXIT

2POST-FORM

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

1KEY-EXIT

2POST-FORM

18.点击“Translations”按钮时:

1TRANSLATIONS

19.点击小叉号关闭时:

1WHEN-WINDOW-CLOSED

2CLOSE-WINDOW

3KEY-EXIT

4POST-FORM

20.选中LOV列表:

1KEY-LISTVAL

2WHEN-NEW-ITEM-INSTANCE

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

1WHEN-NEW-RECORD-INSTANCE

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

3WHEN-NEW-ITEM-INSTANCE

22.光标上下移动时:

1WHEN-NEW-RECORD-INSTANCE

2WHEN-NEW-ITEM-INSTANCE

Tag标签:

 

 

 

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都是当鼠标光标每次落到一个新的blockrecorditem上时触发的,而且就算失败了,也不会发生什么错误。但是when-new-form-instance,只有当form启动时,光标导航到第一个导航块的第一个导航item时触发,如果一个应用有多个form,当光标在各个form之间转换时,并不会触发它。

POST-TEXT-ITEMWHEN-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-……
系列的都是离开当前的blockrecorditem时触发的

WHEN-WINDOW-ACTIVATED

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

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

 

验证代码写在WHEN-VALIDATE-RECORDPRE-INSERT的不同

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

 

Post-QueryWhen-New-Record-Instance关系

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

 

不可见itemwhen-validate-item使用
问题:如果一个item是不可见的,那么改变它的值,还会触发when-validate-item吗?
结果:会触发,但不是在改变它的值后触发,而是在光标移到另一个block时。关闭窗口时也触发了。
测试:设block1item1为不可见,在item2when-validate-itemtem1赋值,运行时,改变item2的值后,在block1的各item间移动光标都没有触发item1when-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 fromsBlock 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不需要FDRCSIDAPP_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 ’事件。

 

转载地址:http://xiffx.baihongyu.com/

你可能感兴趣的文章
路由协议重分发之RIP协议与OSPF协议
查看>>
C# 操作Excel2003
查看>>
手把手教你自己动手恢复坏道硬盘数据
查看>>
【电子基础】电子基础知识·持续更新
查看>>
mysql创建定时执行存储过程任务
查看>>
heartbeat 3.0集群(1)集群原理
查看>>
C#中 Finally中不允许有return
查看>>
Java - 容器详解
查看>>
Synchronized Using
查看>>
Linux下PF_PACKET的使用(todo)
查看>>
Android开发者指南(16) —— Activity and Task Design
查看>>
linux下在jar包中找类是否存在
查看>>
mysql备份与恢复策略
查看>>
PPT2010设置图片透明度
查看>>
Horizon View 6-配置View Connection Server⑷
查看>>
几个负载均衡器的小结
查看>>
如何识别高级的验证码
查看>>
[PYTHON]python 基础笔记(4)
查看>>
写保护下的U盘修复
查看>>
SSRS 2012 表达式 -- 颜色管理示例
查看>>