| Previous | Next |  | Contents | Index | Glossary

## StartProcess

PL/SQL Syntax

`procedure StartProcess`

        (itemtype in varchar2,

         itemkey in varchar2);

Java Syntax

`public static boolean startProcess`

        (WFContext wCtx,

         String itemType,

         String itemKey)

Description

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 itemtype and itemkey before calling StartProcess( ).

Arguments (input) | wCtxWorkflow context information. Required for the Java method only. See: Oracle Workflow Context.
| itemtypeA 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.

> 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: You can pass #SYNCH as the itemkey to create a forced synchronous process. See: Forced Synchronous Processes.

| Previous | Next |  | Contents | Index | Glossary