Setting up stored procedures
TaskMan can execute stored procedures directly, without going through the IDO layer. To do this,TaskMan bundles the stored procedure in a transaction.
This example shows the steps to set up a stored procedure that runs from a form using TaskMan:
- Open the Background Task Definition form and execute Filte-In-Place.
- Initiate a new record, if needed.
-
Specify this information:
- Task Name
- Enter AddProcessErrorLogSp.
This is typically the name of the stored procedure.
- Task Description
- Optionally, specify a helpful task description.
- Executable Name
- Provide the name of the stored procedure.
- Executable Type
- Select SP.
- Maximum Concurrent
- Specify the maximum number of concurrent instances of this
task you want TaskMan to allow.
The default value is 20.
Valid values are positive integers. A value of -1 means any number of concurrent instances of this task are allowed to run, up to other limits imposed on all tasks.
Caution:Do not attempt to use a value of zero (0), as it disables the task completely. - Isolation Level
- Select the transaction isolation level to use when running
stored procedure tasks (Executable
Type is set to SP) or report stored procedures (Executable Type is set to
RPT):
- COMMITTED: All queries run from this stored procedure see only data for which the query can get a shared lock. No reads of uncommitted data are performed.
- UNCOMMITTED: All queries run from this stored procedure can read uncommitted data. Use this option carefully, since it can display data that has not yet been committed in the database.
If no isolation level is set in this form, the stored procedure uses the global Collection Read Mode value from the Process Defaults form. If that value does not exist, the stored procedure uses COMMITTED as the transaction isolation level.
- Save, and close the Background Task Definition form.
- Open your form in the designer (Web Designer in a web client or Design Mode in the Windows client).
- Add a Button component.
-
In the Component > Properties sheet, provide this information:
- Name
- Enter: TestSP
- Caption
- Enter: sTest
-
Create an event for the TestSP button:
- In the Component > Events sheet, next to the Primary field, click the ellipses (•••) button.
- In the Event Handlers dialog box, click New.
-
In the Event Handler
Properties dialog box, provide this information:
- Event
- Enter: RunSP
- Description
- Optionally, provide a helpful event description.
- Type
- Select Run Background Task.
- Next to the Parameters field, click the ellipses (•••) button.
-
In the Event Handler
Parameters dialog box, provide this information:
- Error Message
- Enter: mBackendMessage
- Success Message
- Enter: sSubmitted
- Click Type Specific Parameters.
-
In the Edit Background Task
Name and Parms dialog box, provide this information:
- Task Name
- Enter: AddProcessErrorLogSp
- Task Parms
- Enter: BG~TASKID~,FV(TestMessage)Note: The FV keyword tells the application to enclose the value of TestMessage in single quotes. The BG~TASKID~ substitution keyword is replaced at runtime with the task number.
- Click OK repeatedly until you are back in the Events tab.
- Verify that RunSP is the primary event for the TestSP button.
- Save the form.
- Add an Edit component with a variable called TestMessage as the data source.
- Save the form.
- Exit the designer.
-
Specify a message in the TestMessage Edit component and then submit the task.
The system displays a message box that says: Submitted.
-
Open the Background Task
History form.
When the task completes, the test message shows up in the event log.