Showing posts with label User Hooks. Show all posts
Showing posts with label User Hooks. Show all posts

Thursday, October 28, 2010

User Hooks

Oracle has provided some space for user customization with user hook, it is a predefined structure where you can add you logic according to your business need.In some of public APIs (Mailny in ASO APIs like  ASO_QUOTE_PUB) we have option for it.

There are two type of user hooks :
Pre-processing Hooks: it will execute your custom logic before the API does any actual processing.
In the APIs where there is an option for user hooks you can see this code for pre-processing hooks :
IF (JTF_USR_HKS.ok_to_execute(G_PKG_NAME, l_api_name, 'B', 'C')) THEN
<CALL TO PRE-HOOK> -- Example UPDATE_QUOTE_PRE
<ERROR HANDLING>
END IF;
Here B stands for BEFORE and C for Custom Hooks.

Post-processing Hooks:  it will execute your custom logic after the API did all processing.
For Post hooks you will find :
IF (JTF_USR_HKS.ok_to_execute(G_PKG_NAME, l_api_name, 'A', 'C')) THEN
<CALL TO POST-HOOK>  -- Example UPDATE_QUOTE_POST
<ERROR HANDLING>
END IF;

A stands for AFTER and C for Custom Hooks.

***Note : If you see 'V' instead of 'C', that means it is the space for 'Vertical' hooks. These hooks should not be enabled or disabled by customer and the state must be left unchanged.

Package specification and body are already defined for user hooks, do not touch specification, just add your custom logic in the body and compile the package body.

After successful compilation the user hook body you need to enable your hook to be effective.

UPDATE JTF_USER_HOOKS
        SET EXECUTE_FLAG = 'Y'
 WHERE upper(PKG_NAME) = upper('&ENTER_PACKAGE_NAME')
      AND upper(API_NAME) = upper('&ENTER_API_NAME')
      AND PROCESSING_TYPE = '&ENTER_PROC_TYPE' 
   -- A for POST , B for PRE
     AND USER_HOOK_TYPE = 'C';  
   -- Don't use 'V' here, have already mentioned above.

For disabling use the same script with EXECUTE_FLG = 'N'

Hope it will help to some extent to understand user hooks :)
Feel frre to post your query if you have any doubt.


Reference :  Melalink DocID=373923.1