oracle workflow tutorial ppt

15
Copyright Oracle Corporation, 2000. All rights reserved. ® Selector Functions

description

oracle workflow tutorial ppt

Transcript of oracle workflow tutorial ppt

Page 1: oracle workflow tutorial ppt

Copyright Oracle Corporation, 2000. All rights reserved.®

Selector FunctionsSelector Functions

Page 2: oracle workflow tutorial ppt

Copyright Oracle Corporation, 2000. All rights reserved.®

ObjectivesObjectives

After this lesson you should be able to:

• Create a standard API for a selector/callback function

• Define a selector/callback function

• Call a selector/callback function

After this lesson you should be able to:

• Create a standard API for a selector/callback function

• Define a selector/callback function

• Call a selector/callback function

Page 3: oracle workflow tutorial ppt

Copyright Oracle Corporation, 2000. All rights reserved.®

Item Type Selector FunctionItem Type Selector Function

• An item type can have more than one runnable process activity associated with it.

• PL/SQL selector functions are defined to determine which process activity to run in a particular situation.

• Selector functions can be extended to be a general callback function so that item type context information can be reset as needed if the SQL session is interrupted.

• Associate a Selector Function with an Item Type through the item type properties.

• An item type can have more than one runnable process activity associated with it.

• PL/SQL selector functions are defined to determine which process activity to run in a particular situation.

• Selector functions can be extended to be a general callback function so that item type context information can be reset as needed if the SQL session is interrupted.

• Associate a Selector Function with an Item Type through the item type properties.

Page 4: oracle workflow tutorial ppt

Copyright Oracle Corporation, 2000. All rights reserved.®

Standard API for the Selector/Callback Function

Standard API for the Selector/Callback Function

• You can define one PL/SQL procedure that includes both selector and callback functionality by following a standard API.

• You can define one PL/SQL procedure that includes both selector and callback functionality by following a standard API.

procedure <procedure name>

(itemtype in varchar2,

itemkey in varchar2,

actid in number,

command in varchar2,

resultout out varchar2)

procedure <procedure name>

(itemtype in varchar2,

itemkey in varchar2,

actid in number,

command in varchar2,

resultout out varchar2)

Page 5: oracle workflow tutorial ppt

Copyright Oracle Corporation, 2000. All rights reserved.®

Defining a Selector/Callback FunctionDefining a Selector/Callback Function

• itemtypethe internal name for the item type. Defined in the Oracle Workflow Builder.

• itemkeya string that represents a primary key generated by the workflow-enabled application for the item type. The string uniquely identifies the item within an item type.

• actidthe ID number of the activity that this procedure is called from. This parameter is always null if the procedure is called with the ‘RUN’ command to execute the selector function.

• itemtypethe internal name for the item type. Defined in the Oracle Workflow Builder.

• itemkeya string that represents a primary key generated by the workflow-enabled application for the item type. The string uniquely identifies the item within an item type.

• actidthe ID number of the activity that this procedure is called from. This parameter is always null if the procedure is called with the ‘RUN’ command to execute the selector function.

Page 6: oracle workflow tutorial ppt

Copyright Oracle Corporation, 2000. All rights reserved.®

Defining a Selector/Callback Function (Continued)

Defining a Selector/Callback Function (Continued)

• commanddetermines how to execute the selector/callback function.

• resultouta result may be returned depending on the command used to call the selector/callback function

• commanddetermines how to execute the selector/callback function.

• resultouta result may be returned depending on the command used to call the selector/callback function

Page 7: oracle workflow tutorial ppt

Copyright Oracle Corporation, 2000. All rights reserved.®

Calling a Selector/Callback FunctionCalling a Selector/Callback Function

• RUNto select the appropriate process to start when either of the following conditions occur:

– A process is not explicitly passed to WF_ENGINE.CreateProcess.

– A process is implicitly started by WF_ENGINE.CompleteActivity with no prior call to WF_ENGINE.CreateProcess.

• SET_CTXto establish any context information that a function activity in an item type needs to execute, before a new database session begins.

• TEST_CTXto determine if the current item type context is correct before executing a function.

• RUNto select the appropriate process to start when either of the following conditions occur:

– A process is not explicitly passed to WF_ENGINE.CreateProcess.

– A process is implicitly started by WF_ENGINE.CompleteActivity with no prior call to WF_ENGINE.CreateProcess.

• SET_CTXto establish any context information that a function activity in an item type needs to execute, before a new database session begins.

• TEST_CTXto determine if the current item type context is correct before executing a function.

Oracle Workflow can call the selector/callback function Oracle Workflow can call the selector/callback function with the following commands:with the following commands:

Page 8: oracle workflow tutorial ppt

Copyright Oracle Corporation, 2000. All rights reserved.®

Practice OverviewPractice Overview

This practice covers the following topics:

• Creating additional processes in the WFVACXX item type

• Assigning a Selector function to an Item Type

• Creating a Selector function to choose which process to run based on the item key value

• Testing a Selector function

This practice covers the following topics:

• Creating additional processes in the WFVACXX item type

• Assigning a Selector function to an Item Type

• Creating a Selector function to choose which process to run based on the item key value

• Testing a Selector function

Page 9: oracle workflow tutorial ppt

Copyright Oracle Corporation, 2000. All rights reserved.®

Guided Practice Duplicating a Process

Guided Practice Duplicating a Process

1. In the Workflow Builder Navigator open and expand the <WFVACXX> item type:

a. Drag and drop the Vacation Proposal process onto the WFVACXX item type to create a copy. When the process properties window opens, enter new internal and display names for the duplicate process. For example, WFVACXX_ ALTERNATE _PROCESS and Alternate Vacation Proposal.

b. Open the Alternate Vacation Proposal process diagram. Replace the Vacation Proposal notification <Timeout> to a Loop Counter with a <Timeout> transition back to the Vacation Proposal notification.

1. In the Workflow Builder Navigator open and expand the <WFVACXX> item type:

a. Drag and drop the Vacation Proposal process onto the WFVACXX item type to create a copy. When the process properties window opens, enter new internal and display names for the duplicate process. For example, WFVACXX_ ALTERNATE _PROCESS and Alternate Vacation Proposal.

b. Open the Alternate Vacation Proposal process diagram. Replace the Vacation Proposal notification <Timeout> to a Loop Counter with a <Timeout> transition back to the Vacation Proposal notification.

Page 10: oracle workflow tutorial ppt

Copyright Oracle Corporation, 2000. All rights reserved.®

Guided Practice Assigning a Selector Function

Guided Practice Assigning a Selector Function

2. In the Workflow Builder Navigator open the properties for the <WFVACXX> item type and enter a <package.procedure> value in the Selector field.For example, WFVACXX.SELECTOR.

2. In the Workflow Builder Navigator open the properties for the <WFVACXX> item type and enter a <package.procedure> value in the Selector field.For example, WFVACXX.SELECTOR.

Page 11: oracle workflow tutorial ppt

Copyright Oracle Corporation, 2000. All rights reserved.®

Guided Practice Creating a Selector Procedure

Guided Practice Creating a Selector Procedure

3. Use the standard API format for your PL/SQL specification and body.

3. Use the standard API format for your PL/SQL specification and body.

procedure <procedure name>

(itemtype in varchar2,

itemkey in varchar2,

actid in number,

command in varchar2,

resultout in out varchar2)

procedure <procedure name>

(itemtype in varchar2,

itemkey in varchar2,

actid in number,

command in varchar2,

resultout in out varchar2)

a. Add to your package “WFVACXX” created in practice Les 9-2.

b. Give your procedure the same name assigned as the item type selector <procedure> value.

a. Add to your package “WFVACXX” created in practice Les 9-2.

b. Give your procedure the same name assigned as the item type selector <procedure> value.

Page 12: oracle workflow tutorial ppt

Copyright Oracle Corporation, 2000. All rights reserved.®

Guided Practice RUN processingGuided Practice RUN processing

4. In your SELECTOR procedure include logic for the RUN command:

a. Evaluate the value passed in the item key. If the upper case value of the first four characters is:

– ‘CNTR’ return the internal name of the process with the Loop Counter Timeout implementation

– ‘SELF’ return the internal name of the process with the Self Loop Timeout implementation

– neither value, either raise an error or return one of the processes as the default process

4. In your SELECTOR procedure include logic for the RUN command:

a. Evaluate the value passed in the item key. If the upper case value of the first four characters is:

– ‘CNTR’ return the internal name of the process with the Loop Counter Timeout implementation

– ‘SELF’ return the internal name of the process with the Self Loop Timeout implementation

– neither value, either raise an error or return one of the processes as the default process

Page 13: oracle workflow tutorial ppt

Copyright Oracle Corporation, 2000. All rights reserved.®

Guided Practice Testing a Selector Function

Guided Practice Testing a Selector Function

5. Connect to the Oracle Workflow home page. Log on as any user with “Administrator” privileges.

a. Select the Launch Processes link

b. Select your Item Type link from the list

c. On the Initiate Workflow page enter:

– an item key to exercise your Selector logic (values prefixed with ‘CNTR’, ‘SELF’, etc.)

– a unique user key

– a Process Name of <None> from the poplist

– a requestor and approver

– a from and to date (DD-MON-RRRR)

5. Connect to the Oracle Workflow home page. Log on as any user with “Administrator” privileges.

a. Select the Launch Processes link

b. Select your Item Type link from the list

c. On the Initiate Workflow page enter:

– an item key to exercise your Selector logic (values prefixed with ‘CNTR’, ‘SELF’, etc.)

– a unique user key

– a Process Name of <None> from the poplist

– a requestor and approver

– a from and to date (DD-MON-RRRR)

Page 14: oracle workflow tutorial ppt

Copyright Oracle Corporation, 2000. All rights reserved.®

Guided Practice Monitoring the Results

Guided Practice Monitoring the Results

6. Display the Monitor web pages for your work item.

The process run will appear in the:

– Monitor Process List, Process Name column

– Monitor Activities List, Parent Activity column

– Monitor Diagram, Process Title and Diagram itself

Verify that the expected process was run. If an error occurred in your process, use the Result Exception link in the Activities List to determine the cause.

6. Display the Monitor web pages for your work item.

The process run will appear in the:

– Monitor Process List, Process Name column

– Monitor Activities List, Parent Activity column

– Monitor Diagram, Process Title and Diagram itself

Verify that the expected process was run. If an error occurred in your process, use the Result Exception link in the Activities List to determine the cause.

Page 15: oracle workflow tutorial ppt

Copyright Oracle Corporation, 2000. All rights reserved.®

SummarySummary

In this practice, you should have learned how to:

• Write a PL/SQL procedure to select which process to run

• Assign a Selector function to an item type

• Cause the Workflow Engine to run a Selector function

• Verify that your Selector function returns the process name expected

In this practice, you should have learned how to:

• Write a PL/SQL procedure to select which process to run

• Assign a Selector function to an item type

• Cause the Workflow Engine to run a Selector function

• Verify that your Selector function returns the process name expected