Oracle Workflow Business Event System and PLSQL

26
2UDFOH:RUNIORZ5HOHDVH %XVLQHVV(YHQW6\VWHPDQG 3/64/'HYHORSPHQW*XLGHOLQHV $Q2UDFOH7HFKQLFDO:KLWH3DSHU 2FWREHU

Transcript of Oracle Workflow Business Event System and PLSQL

Page 1: Oracle Workflow Business Event System and PLSQL

������������� ������������������������������������������� ��!����"�����#���������������������������� �����������������������

Page 2: Oracle Workflow Business Event System and PLSQL

Oracle Workflow Release 2.6.2 Business Event System and PL/SQL Development Guidelines Page 2

Page 3: Oracle Workflow Business Event System and PLSQL

Oracle Workflow Release 2.6.2 Business Event System and PL/SQL Development Guidelines Page 3

������������� ������������������������������������������� ��!����"�����#�����������

�$���������������������������������������������������������������������������������������������������������� % ����������������������������������������� ����������������������������������������� % �&�������&������������������������������������'�������������������������� % �&�������&������������������������(���)�*������' ������������������������ % �&��������+�������������' ���������������������������������������������������������������������������� � �&�����������������+����"���' ������������������������������������������������������������������� � �&���������+��������������'����������������������������������������������������������������������� � ,����������������������������%���!�,�&�������������������&��-��������������������������������������������'������������������� � ����������������-������-�����������������"�������.�����������&��&��������������������������������-��&������*�������/�,�'��������������������������������������������������������������������������������������������������������������� 0

1&��������2���-�� ������������������������������������������������������������������������������������������ 3 !������-������� �������������������������������������������������������������������������������������������� 3 ,��������4���������������������������������������������������������������������������������������������� 3 !��"����4��� ������������������������������������������������������������������������������������������� 3 !�����"��������������������������������������������������������������������������������������������������� 3 ������ ���������������������������������������������������������������������������������������������������������� 3 #��������*������ ����������������������������������������������������������������������������������� 3 ������4����(��������)���������������������������������������������������������������������� 3 ������1�-�(��������)�������������������������������������������������������������������������� 3

!������-���������+����"������������������������������������������������������������������������� 3 ��+����+��5������� ����������������������������������������������������������������������������������� 3 1��--����-�.������5�������1�"� ������������������������������������������������������� 6 1��--����-�.������5�������*����� �������������������������������������������������������� 6 1��--����-�.������5�������/-��� ����������������������������������������������������� 6 �$�������.����5��&����(��������) ������������������������������������������������ 6 �$�������.����5������������������������������������������������������������������������������ 6 �$�������.����5� ����!������������������������������������������������������������������� 6 /����5� ����*�������(��7�����)��������������������������������������������������������� 89 /����5�������,����1�"�������������������4����("�����) ������������������������������������������������������������������������������������������������� 89 /����5�����/-��������1�/-����("�����)�������������������������������������� 89 /����5���������("�����) ��������������������������������������������������������������������� 89 /����5������������("�����)��������������������������������������������������������������� 89 !����������5�������4����(��������)�������������������������������������� 89

Page 4: Oracle Workflow Business Event System and PLSQL

Oracle Workflow Release 2.6.2 Business Event System and PL/SQL Development Guidelines Page 4

!����������5�������1�-�(��������)������������������������������������������ 89 !����������5�!�����"������������������������������������������������������������������� 89

�������-��������������������-������������������������������������������������ 88 �������-������������������������� ����������������������������������������������� 88 ������-�,����/����+����������������������������������������������������������������������������������� 8� �����-��������������������������������������������������������������������������������� 8� ������-���������������������������������������������������������������� 8:

�����-������������������������� ��.���������������������������������������������� 8% �&�����&����,�"����������� ���������� ������������������������������������������������� 8% ;1�����-<������������������������������������������������������������������������������������ 8% ���"������� ��.�� �������������������������������������������������������������������������� 8%

������-�������#��������*������� �������������������������������������������������������������� 86 ������-���������+����"���� ����*������� ����������������������������������������������� �9 !����������������-���������������������������������������������������������������������������������������� �8 !����������+����"���� ������������������������������������������������������������������������������ �8 !��������!��"���&��-��������� �������������������������������������������������������������� �8 !�������-��������� ���������������������������������������������������������������������������� �8

�$������-����������������������������=������- ����������������������������������� �� >������!�+�--��-�1�"������������������������������������������������������������������������������������ �: ���"���!�+�-����"�� ������������������������������������������������������������������������������� �:

.��������������������������������������������������������������������������������������������������������������� �? �

Page 5: Oracle Workflow Business Event System and PLSQL

Oracle Workflow Release 2.6.2 Business Event System and PL/SQL Development Guidelines Page 5

������������� ������������������������������������������� ��!����"�����#����������

EXECUTIVE OVERVIEW

1&��+@����������&����������������������+�������"����������������&��&�����+����������&���+������-��""�������������-��&��������������� �������������������������������������������� ���,���$"������"�����"�����������������������������-����������"��-����&��&������������������������������������������������"������-�������������������"����������������*���"������������������&����"��������������������A�"���������������&�������� ���������������

1&�������������������-�������-�������������������-���������������&����������&�������-��&�������������������������

ORACLE WORKFLOW BUSINESS EVENT SYSTEM BASICS

What is the Oracle Workflow Business Event System?

1&�������������������������������""�������������"�����5�

• !����������������-�+���������������

• �-������B�����������������+����"��������&����+���������������

• ������������������&����+�������������������""������������

1&�������������������������������������������������������5�

• .�����B���&��+�&�������"���-����""������������&���&����-�����������������������""�������������

• ���������-�������������+����������+���������$�&��-���

• ���������-���������������-�����""���������

What is the Business Event System (BES) Framework?

,������&�������"������""���&���������������/�,���&������+��������"������+���������-���+����������+������""�������������-��&����������������������������������������

!����"���������������-��&������*������������"����������������&���+���������$�������������-����+���������-������������&����������-��-��������+����������7�������������&����&�������������������������""�������������

Page 6: Oracle Workflow Business Event System and PLSQL

Oracle Workflow Release 2.6.2 Business Event System and PL/SQL Development Guidelines Page 6

What is a business event?

/�+��������������������"��������������&��&���-&��+�������������������������������"�������������*���$��"��A��&���������������������������-&��+����+����������������1&���"���������������������������-&��+�����&����$��"�������+���������������

What is an event subscription?

��������+����"���������+����������������"�������"�������������������&��������-�������5�

• �$������������������� ������

• ������-��&��+������������������"����������������"������

• /����&����������-��-�����-��������/�������� �����-�

��������+����"���������+�����+����������+��������-������������������C��&�����������7��������������������-��&��-���

Why define business events?

������+��������������������������������������������""����������"����������"���+����$���������������B�����"���������������A���������������������"������1&������+���������������������������������""�������A��&��-��������&���+�����������������������������������������B���""��������+�&�����+�������-��������-�������������������B��-�����������""�������������

,���&��"���A��������������������������+������+������--������"������������"������������������-�����/���$��"������&��������+����D+��������������E����--������&�������������������&��������+����&��&������������������������������������������,���&�������������������A�����""������������������+����������

1&������������������������-�����"�������������&���+����������������������������&���""�"������������B�����"����������������������&�"���������&��F�/G�H�+��������"����������&��������������������A��&��D������������.������E�������������������.������������������������+����"�������&����������&��&�������&���������������������-��A��&��&��&����������+���������+��������7���������

I already use Oracle Workflow 2.5. Do I have to make any code changes for Oracle Workflow 2.6 Business Event System?

4���1&���$�����-���������-����/�,���������������������������"��������������������������""�������=�����A��������-�������������&��������������������������&��&����������"������������-��&������������������������*������A������������"���������������������A�"����������������B������""���&������������������

Page 7: Oracle Workflow Business Event System and PLSQL

Oracle Workflow Release 2.6.2 Business Event System and PL/SQL Development Guidelines Page 7

We are considering adding some workflows to our product. Can we launch the Workflows directly instead of using the BES Framework APIs?

4�(���&��&���$��"����������������&�����������)����

I������������&������������������������ �����/�,A�����&����������+������+����"�����&��&�����������&��&��������"���������&�������������&�������A����������������������������������&���������+����"��������&������������

,�������������������&��&�������A������������������������-������������������������������������������&����&�����������������������&������������+���������������

Page 8: Oracle Workflow Business Event System and PLSQL

Oracle Workflow Release 2.6.2 Business Event System and PL/SQL Development Guidelines Page 8

THE EVENT MANAGER

1&��������2���-������������&����-���������������A��-����A�+���������������������+����"�������+����������������

Defining Events

Internal Name

�&��������������������������&��������2���-��A�������������-����������7����������������A��&��&��������C�����������1&������������&��������������������������"������������������������������"�������+��"������(�)������������5��

<company>.<productfamily>.<product>.<component>.<object>.<event>

1&���������������������-���B���&���������������������������������������&������&����

Display Name

1&��!��"����4��������&���������&������&�������������������

Description

/��"������������"�����

Status

�������������&������������+����"������&�""������&��&�����������

�����5������+����"����������&�""������&��&���������

Generate Function

1&��#�������������������������+������� ��/�,��&��&�����-�����������J2���������������&���������������"�����������������

/�����+����"������&��&���7������&�������-����+��-�������������-��&��#�����������������&����+������������

Owner Name (mandatory)

1&��������4�����&����+������"������������

Owner Tag (mandatory)

1&��������1�-��&����+������:��������"�����������

Defining Event Subscriptions

Subscriber: System

1&����������������+���&�������������A��&������������&��&��&����+����"������������������

Page 9: Oracle Workflow Business Event System and PLSQL

Oracle Workflow Release 2.6.2 Business Event System and PL/SQL Development Guidelines Page 9

Triggering Condition: Source Type

�����&����������"�������������&����+����"�����""����������������������������&����+����+��-���������

�����&����������"�����$�����������&����+����"�����""���������������������������+�������+�����-�������&����+����+��-���������

�����&����������"�������������&����+����"�����""���������������������������7�����������&���*K� � �7������

Triggering Condition: Event Filter

��������&���������&����&�����+����"�����������

Triggering Condition: Source Agent

������+������

I���&�������������&�������������$��"�������������,������"���������������-���A��&����&����+����"��������$������������&����&�����--����-������������������������&����-�������

Execution Control: Phase (mandatory)

��������"&�������+�������&����+����"�������"�������&�����������&��&���+����"������&����""������&������������������$����������

G����������������9C66������+����"������&��&�������+���$������������������A�����899������+��������+����"������&��&�������+������������

����������A����������+����"������&����&������"&�������+�����899���&�-&�����!�������-���+����"����"�������-������"�������"��������������������&�������������������&������������+����"����"�������-��

Execution Control: Status

����������+������!���+��������&����+����"������������,���������+�������+����"���A����������������������&����������+����"����������������������A�+��������������-���+���������������������"��������������

Execution Control: Rule Data

��� ��&����+����"������7�����������&��������������

������� ��&����+����"������7�������&����"������������������+��-�����������,������"����������#�����������������������+�������������A�����&�����&���2����-�����

��+����"������&��&�&�����&�� ����!����������2����-���&�����������+�����������("&�������+���������899���-������)���!�������-���+����"����"�������-������"�������"��������������������&���������������

Page 10: Oracle Workflow Business Event System and PLSQL

Oracle Workflow Release 2.6.2 Business Event System and PL/SQL Development Guidelines Page 10

Action: Rule Function (required)

,����������������&�����������������K������������K�������1&������������������������+�������������&���������"���������������+�������������������-��������-�������

,�������������������������������������"������B��������������������

.���������������������������������������&��&�����������������������-��A��&��&�����+�������&����������+�����+���-�������+���-��&����+����"������

Action: Workflow Item Type and Workflow Process Name (optional)

����������������,����1�"�������������������4�����/�������"�������������+���&�����������������������������&�������������������������A��� ���������������A����������������������

���������������������&���$�����������"�������������������������������1&�����������"&����������+����&��-��-��A�������-����������A������&���+����������������&��������"������&��-&����������������������������+����&�������������-�����+��������"�����������������"�������

Action: Out Agent and To Agent (optional)

*������-�����A�������������������������&�����������"�������&������-������������������

Action: Priority (optional)

1&����������������&����7�����������������-��������������4�������*��!����������+����"����A��&��"������������������������&����7�����������-��

Action: Parameters (optional)

1&�����������������������+��������������"������������������L������"����A��&��&�����+�����������+�������������������1&��������L������"����������+����������������&��+�&��������&��������������A������&����&����+����"�����

Documentation: Owner Name (mandatory)

1&��������4�����&����+������"�����������

Documentation: Owner Tag (mandatory)

1&��������1�-��&����+������:��������"�����������

Documentation: Description

/�������������������������-&������������������+����&����+����"�����

Page 11: Oracle Workflow Business Event System and PLSQL

Oracle Workflow Release 2.6.2 Business Event System and PL/SQL Development Guidelines Page 11

BUILDING WORKFLOW PROCESSES USING BUSINESS EVENTS

Receiving Events in a Workflow Process

��������������������+���������������������������������"��������

������"���������������������������+���&��������������������������7������&����&�����������������2>�1�+���� ������������������������ ��������������/������������������������������������+����+���������&���������������

1&�� ����������������������������"������&������������A�������������������������-���������������+������"������������&��������!�������"�"�����"�-�A��&��&������&���+���������������&�������������&��������"�������

G����������������������"������������������������������������+���&����������-����������������/�,���1&���/�,���7�������&����&���������������������"������+����+���������&���������������&�����&�����������������������+��������������A���"���������������&���������������������&������������������"���

����������������������������������������������������������������������� �

�!������������������������������������"������������������� ��!���"��������������������������������������������#������������������������������������������������������������������������ �

Page 12: Oracle Workflow Business Event System and PLSQL

Oracle Workflow Release 2.6.2 Business Event System and PL/SQL Development Guidelines Page 12

Setting Item Attributes

/�+�������������������-�����+��������&���*K�G�41K1��+�������������"����1&���+�������������"���������������-��&������"�"�������(��������-�����������*K�/ /2�1� K�,�1K1��&��&�������������"���899������������"����)�������"�������

SQL> desc wf_event_t

Name Null? Type

----------------------------------------- -------- ----------------------------

PRIORITY NUMBER

SEND_DATE DATE

RECEIVE_DATE DATE

CORRELATION_ID VARCHAR2(240)

PARAMETER_LIST WF_PARAMETER_LIST_T

EVENT_NAME VARCHAR2(240)

EVENT_KEY VARCHAR2(240)

EVENT_DATA CLOB

FROM_AGENT WF_AGENT_T

TO_AGENT WF_AGENT_T

ERROR_SUBSCRIPTION RAW(16)

ERROR_MESSAGE VARCHAR2(4000)

ERROR_STACK VARCHAR2(4000)

�&�����+�������������������-����������������������������"�����A��&��������������������&��������-��������������������������������+�������,���&������������+�������������$����A��&����&����������-��������������&�����������&������������+������,���&������������+������������$���A��&����&����������-�����������������&������������+���������&��������&���������

Raising Events from Workflow

,��������������-��������������������-��������������B���&�������������&�"����&�����"�����A���������@������������+��������������������������"��������.��������������&�����+����+�����&���+�������������A�����&�����&���������"�������������������"�������$����������&��������������+��������������������������"�����A��������"��������"����"�������������&��������������������������1&����"���������������-������������������������+�����+������������"���������&���������+����+������&���+����������������

I���&����"�����&�������������+�����"����������"���+������&��&���������+����"��������&�������������&�������-&���������������������&�����7��������������

�&��������������+��������������������������"�����A��������5�

• !�������&��+������������������&��������2���-���

Page 13: Oracle Workflow Business Event System and PLSQL

Oracle Workflow Release 2.6.2 Business Event System and PL/SQL Development Guidelines Page 13

• .�������� ���������������������������������"������

• �"�������������������������������������������+����������7������

• !��-��&�� �������������������������������"������

• .���-�����&����������������������+�������+��""�������+����������������������������������+�����

�$�����������"�����������������������%&��������'�������������������� ��!�����������������������������������������������������������������(����� �

Sending Business Events from a Workflow Process

!����-���������"�����A���+�������������������-������+�������������������������������������������-����(�������/�������� ����)����&���-��-��&��-&�������+����"����"�������-����1&�������7�������������&�����������������������-�A��&�-&�����&����������������-��&����������+����"��������������&���������&�����&�������-��������+����������

1&��������-�����+�������������������-���������+���������"������������������&������������A���������A�����/-��������1�/-�������

Page 14: Oracle Workflow Business Event System and PLSQL

Oracle Workflow Release 2.6.2 Business Event System and PL/SQL Development Guidelines Page 14

�)������������������������������������������������������������������������������� �

1&�������������������������������"��&������+�������������������������&��&�����+��������������������&������"�"������������&��J2�������������-��"��������1&�������5�

• .�"������������"����5� ������&������"�"��������

• #�����������"����5�#���������&������"�"������������������������������+�����

• ������������"����5��������&����������������������������+�����������������&������"�"������

• J2��.�"����1�-�G�����(!���A�4��+��A�1�$�)5� �������������������J2����-��������&����&�������������-��"������(�������������������)��

• J2��#���1�-�G����5�#����������������J2����-��������&�����������������-��"�������������������������������+����(�������������������)��

• J2��1�������5�/""������J2���������&��������������������-��"������(�������������������)��

Page 15: Oracle Workflow Business Event System and PLSQL

Oracle Workflow Release 2.6.2 Business Event System and PL/SQL Development Guidelines Page 15

RAISING BUSINESS EVENTS FROM PL/SQL CODE

Where should I put calls to raise events?

I�������"��������������������������������$�������&�������"��������"�������������������&����������,���������A�����&������������������-� �����@����+������������������������������A����&�������&��-�"��������������������-�&������������

“Testing” Business Events

��������+����"�����������7������������-�����

I����������������&����&�����������������-���+����"���������-��&�� ����!������������,���&�� ����!�������DM��EA��&����+����"����������7������&������"�"����������"�������-���,���&�� ����!�������D2����-�EA��&����+����"������7������&������"�"������������������-��"���������"�������-���1&�������-��"�����������"����������J2�����������

,����������&��������������&��J2����������(�����/�,��&��&�����-���������&��J2���������)��&����&��+��������������������������A�����&����������������&��&����&��������������+����"��������&���+���������������&��&��������7������&��J2������������1&����������+������-��&����K�����������/�,A��&��&�������������2���/#������&�����������+����"�����&��&���7�������&��J2���������A���M�I�����������&����+����"�������7������&��J2������������1&�������/�,����������������4�4�A�+��������������+����&�������������&�����������������������������&�����������&������������N������&�����������������!��"���&������������&���"�������-��

,����������&��������������&��J2��!������A����������������������&��-�O��&��������������������������������������������&��&���������������-�������7�����A�����-���������&�������-�������7�������

Sample PL/SQL Code

1������������������������ �����A������&��������-����"����5�

declare

/*

** Optional - if complete event data is available, declare these.

** l_xmldocument varchar2(32000);

** l_eventdata clob;

** l_message varchar2(10);

*/

l_parameter_list wf_parameter_list_t := wf_parameter_list_t();

begin

Page 16: Oracle Workflow Business Event System and PLSQL

Oracle Workflow Release 2.6.2 Business Event System and PL/SQL Development Guidelines Page 16

/*

** We know that we are going to raise an event, so

** we will set some parameters now, these will become

** item attributes in any workflow processes that called

** by the business event system due to this business event

** Up to 100 name/value pairs. The fewer the parameters the

** better performance will be.

*/

wf_event.AddParameterToList(p_name=>‘ORG_ID’,

p_value=>’<ORG_ID Value>’,

p_parameterlist=>l_parameter_list);

wf_event.AddParameterToList(p_name=>‘<Parameter Name>’,

p_value=>’<Parameter Value>’,

p_parameterlist=>l_parameter_list);

wf_event.AddParameterToList(p_name=>‘<Parameter Name>’,

p_value=>’<Parameter Value>’,

p_parameterlist=>l_parameter_list);

/*

** ***** OPTIONAL *****

** In most cases, you do not need to do this.

**

** If the complete event data is easily available, we can

** optionally test if any subscriptions to this event

** require it (rule data = Message).

** From PL/SQL, you probably won’t need to do this

**

** l_message := wf_event.test('<EVENT_NAME>');

**

** If we do require a message, and we have the message now,

** set it; else we can just rely on the Event Generate

** Function callback code. Then Raise the Event with the

** required parameters. From PL/SQL, you probably won’t need

** to do this.

**

** if l_message = 'MESSAGE' then

**

** if l_xmldocument is not null then

** dbms_lob.createtemporary(l_eventdata, FALSE, DBMS_LOB.CALL);

** dbms_lob.write(l_eventdata, length(l_xmldocument), 1,

Page 17: Oracle Workflow Business Event System and PLSQL

Oracle Workflow Release 2.6.2 Business Event System and PL/SQL Development Guidelines Page 17

** l_xmldocument);

** -- Raise the Event with the message

** wf_event.raise( p_event_name => ’<EVENT_NAME>’,

** p_event_key => ’<EVENT_KEY>’,

** p_event_data => l_eventdata,

** p_parameters => l_parameter_list);

**

** else

**

** -- Raise the Event without the message

** -- The Generate Function Callback will create the XML Document

** -- Also possible that an API might be called from here

** -- to generate the XML document

** wf_event.raise( p_event_name => ’<EVENT_NAME>’,

** p_event_key => ’<EVENT_KEY>’,

** p_parameters => l_parameter_list);

**

** end if;

**

** elsif

**

** l_message = ’KEY’ then

** -- Raise the Event

** wf_event.raise( p_event_name => <EVENT_NAME>,

** p_event_key => <EVENT_KEY>,

** p_parameters => l_parameter_list);

**

** end if;

*/

/*

** Raise the event with no XML document, if an XML

** document is required to be generated, the Generate Function

** will automatically be run

*/

wf_event.raise( p_event_name => <EVENT_NAME>,

p_event_key => <EVENT_KEY>,

p_parameters => l_parameter_list);

l_parameter_list.DELETE;

Page 18: Oracle Workflow Business Event System and PLSQL

Oracle Workflow Release 2.6.2 Business Event System and PL/SQL Development Guidelines Page 18

/*

** Up to your own code to commit the transaction

*/

commit;

/*

** Up to your code to handle any major exceptions

** The Business Event System is unlikely to return any errors

** As long as the Raise can be submitted, any errors will be placed

** on the WF_ERROR queue and a notification sent to SYSADMIN

*/

exception

when others then

<YOUR ERROR CODE>;

end;

Page 19: Oracle Workflow Business Event System and PLSQL

Oracle Workflow Release 2.6.2 Business Event System and PL/SQL Development Guidelines Page 19

WRITING EVENT GENERATE FUNCTIONS

�&��������������������������&�����������������������A������������-����#�����������������&�������"�������&����"����������������(��"����������J2���������)������&������������A���������A�����"�����������������

1&��������2���-����������&��#�����������������&�������""����������������&�����������&���"������-����������������������"�������-��&����������+����"�������&���������&��&���7�������&���������������1&��#�������������������������&������������������+��������

��������������������&����#���������������5�

• �*K�G�41K*>4.1,�4�K�M#�#�4� /1��O�-���������J2������������&��&���"��������������������������������������

1&������ �����������&���-����������&������������������&�����&��������-����������/�,5�

function <function_name> (p_event_name in varchar2,

p_event_key in varchar2

p_parameter_list in wf_parameter_list_t

default null)

return clob;

1&����-�����������&����������������������5�

• "K�����K����5�1&�������������������&����������

• "K�����K��5�/������-�-����������&����&�����������������&�����"�-�������""���������1&��������������7�������������������"�������������������&����������

• "K"��������K����5�/��"�����������������������"������������������������"���������&���������

Page 20: Oracle Workflow Business Event System and PLSQL

Oracle Workflow Release 2.6.2 Business Event System and PL/SQL Development Guidelines Page 20

WRITING EVENT SUBSCRIPTION RULE FUNCTIONS

�&������������������������+����"���A���������������������� ���������������������������������&��&�����$�������+���&��!��"���&�����1&������������������������&��+�&��������&����������+����"���N�������������&����������-�����������&���������"�����A��������������&�������/�,�����7����������-����

��������������������&����������������������5�

• *+,"-. �+�-.!,"-.�O��&�������&������������������������������������������+����"������,��������������������&����������-���������������/�,��

• *+,"-. "")","-.�O��&�������&�������������������&�����������������+����"��������&�����������"����D� � E�

,��������&����������������������������A�������&���"�-������������"����5�

function <function_name> (p_subscription_guid in raw,

p_event in out WF_EVENT_T) return varchar2 is

<local declarations>

begin

<your executable statements>

<optional code for WARNING>

WF_CORE.CONTEXT(’<package name>’, ’<function name>’,

p_event.getEventName( ), p_subscription_guid);

WF_EVENT.setErrorInfo(p_event, ’WARNING’);

return ’WARNING’;

<your executable statements>

return ’SUCCESS’;

exception

when others then

WF_CORE.CONTEXT(’<package name>’, ’<function name>’,

p_event.getEventName( ), p_subscription_guid);

WF_EVENT.setErrorInfo(p_event, ’ERROR’);

return ’ERROR’;

end;

.����������������������������������������A����������������"��������������-�����&��+�&��������&���""��������"���������

Page 21: Oracle Workflow Business Event System and PLSQL

Oracle Workflow Release 2.6.2 Business Event System and PL/SQL Development Guidelines Page 21

DEFERRED PROCESSING

1&���������������������������������������""���5�

• !����������+����"�����O��&�������&�������&����������������������&���������������+����"�����

• !�����������"���&��-����������

• !�������-����������

!���������������������+����"���������"���������&���*K!�*� �!��-�����

��������������������������������������������������������*�������������.��������������������������������*+,�+""����������

Deferred Subscriptions

�&�����+��������������������"���&�������&������A�������+����"��������&���"&������9���66������+��"����������/�����+����"��������&���"&�����+���66������+�������������1&����������-���+������&����&��-��-�����O��&����+����"����"&��������+���&��-������&�������������B������

Deferred Dispatching of Events

>�����������$�������������������A��&��������������+�������������������7������&����&�����"���&��-����&����������+�������&�������1&������&�����-������������������������

1&����������7����������&���������&��������-������������+����������������������5�

Wf_event.SetDispatchMode(‘ASYNC’);

/���+��������������������������&���������������+�������������1��������&����������������������+�����"���&�������&������A���������&��������-�����������5�

Wf_event.SetDispatchMode(‘SYNC’);

Deferring of Workflows

������"�������-�����+�������������������+�����������������&�������� ���������������1�"������A����������������������"������+��������-��&����������������������+��-��������&���%9��

Page 22: Oracle Workflow Business Event System and PLSQL

Oracle Workflow Release 2.6.2 Business Event System and PL/SQL Development Guidelines Page 22

EXTENDING BUSINESS EVENT SYSTEM ERROR HANDLING

/����������&�������������-���������"������������"������+���&����������-���A��������&����&���������������"��������������&��A���������C�������������"��������������&���������&������-�����&�������������������������������&���������������

����������A��������������������-��������������������-���+����"����"�������-A��������-�����"������&���*K� � ��-������,���&�� ����*���������������*�"/0/1A���+����"����"�������-������������,���&�� ����*���������������"")"A���+����"����"�������-�����&�����������������������A�����������+����"������&��&����������������������&�������������������+����

�����������A�����-���������������������*K� � A�������������7�����-��&��������������-�A��&��!��"���&������������+������+����"��������&������������&���������1�"����� � ���,���&�������������+������+����"���������&������������&���������1�"����� � A��&����&����+����"�������&���������""��������������$"���������������&���������1�"����� � ���������

1&���������������"��������������������������������������������&���*� � ��������"�A��&��!�*/>�1K�G�41K� � �"��������,��������&���+����������������"�������������+�������������A�������������������������������������"�����

Page 23: Oracle Workflow Business Event System and PLSQL

Oracle Workflow Release 2.6.2 Business Event System and PL/SQL Development Guidelines Page 23

USEFUL DEBUGGING TIPS

1&�������������������������������������������+�-����-��&��&�������������&�������"�����������-������-��������������+�--��-��������������

I���&���������������&����+�-����-�����������"���������������&�"����N�����&��������+������������-�������-��������������� ������"�����������&�"�����&��������������"������������7�����-������7���&��&����������������&���-�������������������+�-������

1�������+�--��-��A���������$�������&��������-�� �5�

set serveroutput on size 100000

begin

dbms_output.put_line(’=============================================’);

wf_log_pkg.wf_debug_flag := TRUE;

end;

/

1������&����+�--��-���5�

begin

wf_log_pkg.wf_debug_flag := FALSE;

end;

/

Sample Debug Output

�&���������-��&���������""������������������������������ �P����A�����-����&��������-���+�-������-��5�

Level:6 Module:dispatch Time:21-06-2001 16:03:35

>>> Message: dispatching oracle.apps.wf.event.wf.send

Level:6 Module:dispatch Time:21-06-2001 16:03:35

>>> Message: found a LOCAL subscription

Level:6 Module:workflow_protocol Time:21-06-2001 16:03:35

>>> Message: calling wf_engine.event()

Priority: 50

SendDate: 06-21-2001 04:06:35

ReceiveDate:

CorrelationID:

Begin Parameter list

Name: ACKREQ Value: Y

Name: SNDACK Value: N

Name: SUB_GUID Value: 0CDF0769828244E0852543AB8E15142B

End Parameter list

EventName: oracle.apps.wf.event.wf.send

Page 24: Oracle Workflow Business Event System and PLSQL

Oracle Workflow Release 2.6.2 Business Event System and PL/SQL Development Guidelines Page 24

EventKey: 1602

EventData:

Level:6 Module:dispatch Time:21-06-2001 16:03:36

>>> Message: ran wf_rule.workflow_protocol and returned SUCCESS

1&������+�-������-����&�5�

• 1&��������+���-����"���&���

• ,����������&��-���+����"���������������

• �&���������������������$������A��&������������������

• 1&����"������&�������������-���������&����+����"���������$�������

• 1&����������������&���������������

CONCLUSION

*�����-��&���������"�����-���������������&��"����+�����"��������""�������������-��&��������������������������������������������� ���

Page 25: Oracle Workflow Business Event System and PLSQL

Oracle Workflow Release 2.6.2 Business Event System and PL/SQL Development Guidelines Page 25

Page 26: Oracle Workflow Business Event System and PLSQL

Oracle Workflow Release 2.6.2 Business Event System and PL/SQL Development Guidelines

October 2001

Author: Mark Craig

Contributing Authors: Kevin Hudson, Clara Jaeckel, Janet Lee, Donna Ng, Debbie Quezadaz

Oracle Corporation

World Headquarters

500 Oracle Parkway

Redwood Shores, CA 94065

U.S.A.

Worldwide Inquiries:

Phone: +1.650.506.7000

Fax: +1.650.506.7200

www.oracle.com

Oracle is a registered trademark of Oracle Corporation. Various

product and service names referenced herein may be trademarks

of Oracle Corporation. All other product and service names

mentioned may be trademarks of their respective owners.

Copyright © 2001 Oracle Corporation

All rights reserved.