DECLARE
x_event_parameter_list wf_parameter_list_t;
x_user_id INTEGER :=
x_user_name VARCHAR2(100) :=
x_param wf_parameter_t;
x_event_name VARCHAR2(100) :=
x_event_key VARCHAR2(100) := 'Event Key';
x_parameter_index NUMBER := 0;
BEGIN
x_event_parameter_list := wf_parameter_list_t();
--Lets add the first value to the Event Parameter i.e. user_id
x_param := wf_parameter_t(NULL
,NULL);
x_event_parameter_list.EXTEND;
x_param.setname('XX_TEST_USER_ID');
x_param.setvalue(x_user_id);
x_parameter_index := x_parameter_index + 1;
x_event_parameter_list(x_parameter_index) := x_param;
--Lets add the second value to the Event Parameter i.e. User Name
x_param := wf_parameter_t(NULL
,NULL);
x_event_parameter_list.EXTEND;
x_param.setname('XX_TEST_USER_NAME');
x_param.setvalue(x_user_name);
x_parameter_index := x_parameter_index + 1;
x_event_parameter_list(x_parameter_index) := x_param;
wf_event.RAISE(p_event_name => x_event_name
,p_event_key => x_event_key
,p_parameters => x_event_parameter_list
/*,p_event_data => p_data*/
);
END;
To get the latest list of events, run
SELECT owner_name, NAME, statusFROM wf_eventsWHERE upper(NAME) LIKE '%' upper('&event_name') '%'AND status = 'ENABLED'
Create a pl/sql function xx_test_event_01 that will be executed when the event is raised.
All that this pl/sql will do is to create a record in table xx_event_result.
When invoking the event, two parameters namely user_id and user_name will be passed. It is the value of these parameters that will be inserted into the tables.
CREATE OR REPLACE FUNCTION xx_test_event_01(
p_subscription_guid IN RAW
,p_event IN OUT NOCOPY wf_event_t)
RETURN VARCHAR2 IS
l_user_name VARCHAR2(100);
l_user_id INTEGER;
BEGIN
--read the parameters values passed to this event
l_user_id := p_event.getvalueforparameter('XX_TEST_USER_ID');
l_user_name := p_event.getvalueforparameter('XX_TEST_USER_NAME');
INSERT INTO xx_event_result
(x_user_id
,x_user_name)
VALUES
(l_user_id
,l_user_name);
COMMIT;
RETURN 'SUCCESS';
END xx_test_event_01;
/
More information visit :
http://oracle.anilpassi.com/workflows-business-events-training-lesson-4-2.html
No comments:
Post a Comment