You are on page 1of 17

How to Create a Custom Event Alert to Fire against a Custom Table?

An event alert is a database trigger that tells you when data in an object within the database has been changed. Event alerts can be configured to trigger an action, like sending an email to a user or running some concurrent programs. The post will provide you a step-by-step guide on how to create a custom event alert, which will fire when a row in a custom table is updated. The update can be the result of an insert or update DML statement.

Step 1: Create your Custom schema:

You should have a Custom schema within the database where you can create your custom tables. If you already have a custom schema in use that is created by the DBA, you can simply use them.

Step 2: Create your Custom Application:

You should have a Custom Application. If your apps instance already has it, then simply use it or, you can create a custom application via the below navigation:

Log into Applications as the System Administrator and navigate to: Application –> Register.

How to Create a Custom Event Alert to Fire against a Custom Table? An event alert

Step 3: Register the Custom schema in AOL:

Register the Custom schema with the Application Object Library.

Log into Oracle Applications as the System Administrator and navigate: Security –> ORACLE –> Register.

Step 4: Add the Custom schema to Data Group: You need to add the custom user/schema

Step 4: Add the Custom schema to Data Group:

You need to add the custom user/schema to a data group. You can do this by logging into Oracle Applications as the System Administrator and navigate:

Security –> ORACLE –> DataGroup.

The following is an example row for your user registration:

Data Group: Standard

Description: Standard Data Group

Step 5: Create your table in Custom Schema: Create your table in Custom Schema. Give grants

Step 5: Create your table in Custom Schema:

Create your table in Custom Schema. Give grants to Apps and also create the synonym in Apps.

Step 6: Register your custom table in AOL:

Register your custom table in Oracle Application via the API’s of AD_DD Package.

Procedures in the AD_DD Package:

//Procedure REGISTER_TABLE procedure register_table ( p_ap p_tab_name in varchar2, p_tab_type in varchar2,
//Procedure REGISTER_TABLE
procedure register_table ( p_ap
p_tab_name in varchar2,
p_tab_type in varchar2,

1

//Procedure REGISTER_TABLE

2

3

procedure register_table ( p_appl_short_name in varchar2,

4

p_tab_name in varchar2,

5

p_tab_type in varchar2,

6

p_next_extent in number default 512,

7

p_pct_free in number default 10,

8

p_pct_used in number default 70);

9

1

//Procedure REGISTER_COLUMN

0

1

procedure register_column (p_appl_short_name in varchar2,

1

p_tab_name in varchar2,

1

p_col_name in varchar2,

2

p_col_seq in number,

1

p_col_type in varchar2,

3

p_col_width in number,

1

p_nullable in varchar2,

4

p_translate in varchar2,

1

p_precision in number default null,

5

p_scale in number default null);

1

6

//Procedure DELETE_TABLE

1

7

procedure delete_table (p_appl_short_name in varchar2,

1

p_tab_name in varchar2);

8

1

//Procedure DELETE_COLUMN

9

2

procedure delete_column (p_appl_short_name in varchar2,

0

p_tab_name in varchar2,

2

p_col_name in varchar2);

1

2

2

2

3

2

4

2

5

2

6

2

7

2

8

2

9

3

0

3

1

3

2

VARIABLE NAMES

DESCRIPTION

p_appl_short_name

The application short name of the application that owns the table (usually

 

your custom application).

p_tab_name

The name of the table (in uppercase letters).

p_tab_type

Use ’T’ if it is a transaction table (almost all application tables), or ’S’ for a”

seed data” table (used only by Oracle Applications products).

p_pct_free

The percentage of space in each of the table’s blocks reserved for future updates to the table (1–99). The sum of p_pct_free and p_pct_used must

be less than 100.

p_pct_used

Minimum percentage of used space in each data block of the table (1–99).

The sum of p_pct_free and p_pct_used must be less than 100.

p_col_name

The name of the column (in uppercase letters).

p_col_seq

The sequence number of the column in the table (the order in which the

column appears in the table definition).

p_col_type

The column type (’NUMBER’, ’VARCHAR2’, ’DATE’, etc.).

p_col_width

The column size (a number). Use 9 for DATE columns, 38 for NUMBER

columns (unless it has a specific width).

p_nullable

Use ’N’ if the column is mandatory or ’Y’ if the column allows null values.

p_translate

Use ’Y’ if the column values will be translated for an Oracle Applications product release (used only by Oracle Applications products) or ’N’ if the Values are not translated (most application columns).

p_next_extent

The next extent size, in kilobytes. Do not include the ’K’.

p_precision

The total number of digits in a number.

p_scale

The number of digits to the right of the decimal point in a number.

Useful API to register a Table in Apps:

DECLARE

 

v_appl_short_name

VARCHA

v_tab_name

VARCHAR2

v_tab_type

VARCHAR2

v_next_extent

NUMBER :=

 
  • 1 DECLARE

  • 2 VARCHAR2 (40) := 'XXCUST';

v_appl_short_name

  • 3 VARCHAR2 (32) := 'TXN_ACK_LOG'; -- Change the table name if you require

v_tab_name

  • 4 VARCHAR2 (50) := 'T';

v_tab_type

  • 5 NUMBER := 512;

v_next_extent

  • 6 v_pct_free NUMBER;

  • 7 v_pct_used NUMBER;

 
  • 8 BEGIN

  • 9 -- Unregister the custom table if it exists

10

ad_dd.delete_table (p_appl_short_name

=> v_appl_short_name,

11

p_tab_name

=> v_tab_name);

12

13

-- Register the custom table

 

14

FOR tab_details IN (SELECT table_name,

15

tablespace_name,

16

pct_free,

17

pct_used,

18

ini_trans,

19

max_trans,

20

initial_extent,

21

next_extent

22

FROM dba_tables

23

WHERE table_name = v_tab_name)

 

24

LOOP

25

ad_dd.register_table (

 

26

p_appl_short_name

=> v_appl_short_name,

27

p_tab_name

=> tab_details.table_name,

28

p_tab_type

=> v_tab_type,

29

p_next_extent

=> NVL (tab_details.next_extent, 512),

30

p_pct_free

=> NVL (tab_details.pct_free, 10),

31

p_pct_used

=> NVL (tab_details.pct_used, 70));

32

END LOOP;

33

34

-- Register the columns of custom table

 

35

FOR all_tab_cols IN (SELECT column_name,

36

column_id,

37

data_type,

38

data_length,

39

nullable

40

FROM all_tab_columns

41

WHERE table_name = v_tab_name)

42

LOOP

43

ad_dd.register_column (p_appl_short_name

=> v_appl_short_name,

44

p_tab_name

=> v_tab_name,

45

p_col_name

=> all_tab_cols.column_name,

46

p_col_seq

=> all_tab_cols.column_id,

47

p_col_type

=> all_tab_cols.data_type,

48

p_col_width

=> all_tab_cols.data_length,

49

p_nullable

=> all_tab_cols.nullable,

50

p_translate

=> 'N',

51

p_precision

=> NULL,

52

p_scale

=> NULL);

53

END LOOP;

54

55

FOR all_keys IN (SELECT constraint_name, table_name, constraint_type

56

FROM all_constraints

 

57

WHERE constraint_type = 'P' AND table_name = v_tab_name)

58

LOOP

59

ad_dd.register_primary_key (

 

60

p_appl_short_name

=> v_appl_short_name,

61

p_key_name

=> all_keys.constraint_name,

62

p_tab_name

=> all_keys.table_name,

63

p_description

=> 'Register primary key',

64

p_key_type

=> 'S',

65

p_audit_flag

=> 'N',

66

p_enabled_flag

=> 'Y');

67

68

FOR all_columns

69

IN (SELECT column_name, POSITION

70

FROM dba_cons_columns

71

WHERE table_name = all_keys.table_name

72

AND constraint_name = all_keys.constraint_name)

73

LOOP

74

ad_dd.register_primary_key_column (

75

p_appl_short_name

=> v_appl_short_name,

76

p_key_name

=> all_keys.constraint_name,

77

p_tab_name

=> all_keys.table_name,

78

p_col_name

=> all_columns.column_name,

79

p_col_sequence

=> all_columns.POSITION);

80

END LOOP;

81

END LOOP;

82

83

COMMIT;

84

END;

Once the table registration API completes successfully, log in to Oracle Apps.

Responsibility: Application Developer

Navigation: Application > Database > Table

Query for the custom table, ‘TXN_ACK_LOG’

Also you can verify from below backend tables:  FND_TABLES  FND_COLUMNS  FND_PRIMARY_KEYS  FND_PRIMARY_KEY_COLUMNS

Also you can verify from below backend tables:

FND_TABLES

FND_COLUMNS

FND_PRIMARY_KEYS

FND_PRIMARY_KEY_COLUMNS

Step 7: Run APPS_DDL and APPS_ARRAY_DDL packages against your custom schema:

After creating and registering your objects and schema, you need to run the APPS_DDL and APPS_ARRAY_DDL packages against your user/schema. You must run the scripts from the $AD_TOP/admin/sql directory in the order noted below. Please remember that you must run these scripts from the “APPS” user/schema account.

  • 1. adaddls.pls

  • 2. adaaddls.pls

4. adaaddlb.pls

General Syntax Form:

SQL> @$AD_TOP/admin/sql/adaddls.pls <SYSTEM_PW> <SCHEMA_NAME> <SCHEMA_PW>

SQL> @$AD_TOP/admin/sql/adaaddls.pls <SYSTEM_PW> <SCHEMA_NAME> <SCHEMA_PW>

SQL> @$AD_TOP/admin/sql/adaddlb.pls <SYSTEM_PW> <SCHEMA_NAME> <SCHEMA_PW>

SQL> @$AD_TOP/admin/sql/adaaddlb.pls <SYSTEM_PW> <SCHEMA_NAME> <SCHEMA_PW>

You can run the following to validate whether these two packages exist under your custom schema or not:

select object_name, object_type, status from dba_objects where object_name in (‘APPS_DDL’,’APPS_ARRAY_DDL’) and owner = ‘CUSTOM_SCHEMA’;

Step 8: Create a custom request group:

You need to create a custom request group that will hold your custom and/or standard requests within a custom responsibility. You can do this by logging into Oracle Applications as System Administrator and navigate:

Security –> Responsibility –> Request.

Step 9: Create a custom responsibility:

After creating your custom request group, you need to create a custom responsibility for your custom user/schema. You can do this by logging into Oracle Applications as System Administrator and navigate:

Security –> Responsibility –> Define

You have now completed the steps on how to create and register a customer schema in the Oracle Applications. The next section discusses how you can create the alert in Oracle Alerts.

Step 10: Create the Event Alert:

You log into the Oracle Applications, choose the Alert Manager Responsibility and then navigate:

Alert –> Define

You can create a new alert as follows:

1] You enter the appropriate general information for your alert:

Application = XXCUST Receivables

Name = xxcust_event_alert

Description = My event alert test

Type = Event

2] You enter the Event Alert Details section for your alert and then check the “After Insert” and “After Update” boxes:

Application = XXCUST Receivables

Table = TXN_ACK_LOG

3] You enter the select statement.

4] You can now click on the Action Button and create the detail action for your event alert, by the following steps:

  • a. You can set the general action parameters:

Action Name = xxcust_event_action

Action Description = xxcust event detail action

Action Level = Detail

  • b. You can click on action details:

At this point, you can choose an action type, like a message and complete the message detail.

NOTE: The article assumes that the integration between Oracle Applications and an operating system mail server is already configured correctly.

5] You can navigate back to the main Alert Definition form, and click on the Action Set button, which will allow you to enter a new action set. Below is a basic example consistent with the example code in this entry.

Seq = 1

Action Set Name = xxcust_event_actionset

Then, you need to check the “Enabled” check box so that your event alert is enabled to run. You should set members as follows:

Seq = 1

Action = xxcust_event_action

Type = Action: Message

Seq = 2

Action = Exit Action Set Successfully

Type = Exit from Action Set successfully

For detail information on how to create Event Alert please go through the Oracle Alert User’s Guide.

References:

  • 1. Oracle Alert User’s Guide

  • 2. Metalink Note: Beginner’s Guide: Create a Custom Event Alert to Fire against a Custom Table (Doc ID 103418.1)

  • 3. Metalink Note: Integrating Custom Applications with Oracle Applications (Doc ID 176852.1)

  • 4. Blog: oraclemaniac.com

How to design Periodic Alert to send emails?

December 1, 2011

AOL

1] Go to ‘Alert Manager’ responsibility and navigate Alert > Define.

 Enter the name of the application that will own the alert  Enter a suitable

Enter the name of the application that will own the alert

Enter a suitable Name of the alert (up to 50 characters), and give it a meaningful description (up to 240 characters).

Select a frequency for your periodic alert. You can choose from nine frequency options:

  • 1. On Demand

  • 2. On Day of the Month

  • 3. On Day of the Week

  • 4. Every N Calendar Days

  • 5. Every Day

  • 6. Every Other Day

  • 7. Every N Business Days

  • 8. Every Business Day

Choose ‘On Demand’ frequency when you are developing a periodic alert so that you can test your alert at any time you want. When you will sure that the alert is working fine, then you can change the frequency as per business need.

Depending on the frequency you choose in the previous step, the Start Time and End Time fields become enabled. You may also specify the number of times within a 24-hour period that Oracle Alert checks your alert.

Specify a value in the Keep _ Days field to indicate the number of days of exceptions, actions, and response actions history you want to keep for this alert.

Specify a value in the End Date field if you want to disable your alert by a certain date.

Enter a SQL Select statement that retrieves all the data your alert needs to perform the actions you plan to define.

Note:

Your periodic alert Select statement must include an INTO clause that contains one output for each column selected by your Select statement.

Identify any inputs with a colon before the name, for example, :INPUT_NAME.

Identify any outputs with an ampersand (&) before the name, for example, &OUTPUT_NAME.

Do not use set operators in your Select statement.

You can use PL/SQL functions in your Select statement to fetch complex business logic.

Click on the ‘Verify’ button to check the select statement is correct.

 Choose ‘On Demand’ frequency when you are developing a periodic alert so that you can

Click on the ‘Run’ button to execute the Select statement.

Once you are satisfied with the SQL statement, save your work. 2] You can view all

Once you are satisfied with the SQL statement, save your work.

2] You can view all the input and output column details in ‘Alert Details’ Tab. The Alert Details window includes information such as which Application installations you want the alert to run against, what default values you want your inputs variables to use, and what additional characteristics you want your output variables to have.

3] After you define your alert you need to create the actions you want your alert to perform. For that click on the ‘Actions’ tab.

 Enter a name (up to 80 characters) and description (up to 240 characters) for your
Enter a name (up to 80 characters) and description (up to 240 characters) for your alert action.
Select a level for your action: Detail, Summary, or No Exception.
  • 1. Detail action: performs once for each individual exception found

  • 2. Summary action: performs once for all exceptions found

  • 3. No exception action: performs when no exceptions are found.

4] Click on ‘Action Details’ tab to display the Action Details window.

 Select the Action Type field as ‘Message’ if you want to send emails. Other action

Select the Action Type field as ‘Message’ if you want to send emails. Other action types are: Concurrent Program, Operating System Script and SQL Script.

Specify the electronic mail IDs of the recipients you want to send your message to in the To field.

If you list more than one recipient in any of these recipient fields, separate each recipient by a space, or a comma, or a combination of the two.

You can enter as many recipients as you want, up to 240 characters.

You can also enter alert outputs or response variables in any of the alert detail fields. Oracle Alert automatically substitutes the associated output value when checking the alert or the associated response variable value when reading the response.

Save your changes.

5] Click on ‘Action Sets’ tab in the main Alert Window.

 Once you create your alert actions, you must include them in an enabled action set

Once you create your alert actions, you must include them in an enabled action set for Oracle Alert to perform during an alert check. An action set can include an unlimited number of actions and any combination of actions.

Enter a Sequence number that lets you order the execution of action sets during an alert check.

Give any suitable name and description.

Check Suppress Duplicates if you want Oracle Alert to suppress the actions in this action set if the exception found is a duplicate that occurred during the last alert check.

6] Click on ‘Action Set Details’ tab.

 Once you create your alert actions, you must include them in an enabled action set

Go to ‘Members’ tab.

Find and attach the action that is created in Step 3.

Save the changes.

7] Since it is an ‘On Demand’ periodic alert, we can run the alert at any time we want. For that go to Request > Check and enter the alert details. Then click on ‘Submit Request’.

 This will fire one concurrent program which you can view by going through the navigation:
This will fire one concurrent program which you can view by going through the navigation: Request > View
View the Log and Output files of the concurrent program to find that the alert is fired successfully.

Done…check your mailbox and you should get emails that are sent from Oracle Alerts