procedure StartProcess (itemtype in varchar2, itemkey in varchar2);
public static boolean startProcess (WFContext wCtx, String itemType, String itemKey)
Begins execution of the specified process. The engine locates the activity marked as START and then executes it. CreateProcess() must first be called to define the item type and item key before calling StartProcess().
Caution: Although you can make a call to CreateProcess() and StartProcess() from a trigger to initiate a workflow process, you should avoid doing so in certain circumstances. For example, if a database entity has headers, lines and details, and you initiate a workflow process from an AFTER INSERT trigger at the header-level of that entity, your workflow process may fail because some subsequent activity in the process may require information from the entity's lines or details level that is not yet populated.
Caution: The Workflow Engine always issues a savepoint before executing each activity so that it can rollback to the previous activity in case an error occurs. Because of this feature, you should avoid initiating a workflow process from a database trigger because savepoints and rollbacks are not allowed in a database trigger.
If you must initiate a workflow process from a database trigger, you must immediately defer the initial start activities to a background engine, so that they are no longer executing from a database trigger. To accomplish this:
Set the cost of the process start activities to a value greater than the Workflow Engine threshold (default value is 0.5)
or
Set the Workflow Engine threshold to be less than 0 before initiating the process:
begin save_threshold := WF_ENGINE.threshold; WF_ENGINE.threshold := -1; WF_ENGINE.CreateProcess(...); WF_ENGINE.StartProcess(...); --Always reset threshold or all activities in this --session will be deferred. WF_ENGINE.threshold := save_threshold; end
(This method has the same effect as the previous method, but is more secure as the initial start activities are always deferred even if the activities' costs change.
Note: To begin execution of several instances of the same workflow process at once, call WF_ENGINE_BULK.StartProcess instead. See: WF_ENGINE_BULK.StartProcess.
| wCtx | Workflow context information. Required for the Java method only. See: Oracle Workflow Context. |
| itemtype | A valid item type. |
| itemkey | A string derived from the application object's primary key. The string uniquely identifies the item within an item type. The item type and key together identify the process. See: CreateProcess.
Note: You can pass #SYNCH as the item key to create a forced synchronous process. See: Synchronous, Asynchronous, and Forced Synchronous Processes. Note: The item key for a process instance can only contain single-byte characters. It cannot contain a multibyte value. |
Example
The following code excerpt shows an example of how to call startProcess() in a Java program. The example code is from the WFTest.java program.
// start a process
if (WFEngineAPI.startProcess(ctx, iType, iKey))
System.out.println("Process Started successfully");
else
{
System.out.println("launch failed");
WFEngineAPI.showError(ctx);
}