Running stored procedures

Note: This topic applies to only on-premises environments.

TaskMan can execute stored procedures directly, without going through the IDO layer. To do this, TaskMan bundles the stored procedure in a transaction.

The following example shows the steps to set up a stored procedure that runs through TaskMan from a form:

  1. Use the Background Task Definition form to set up a record of type SP with the name of the stored procedure as the task name.

    For example, create a task called AddProcessErrorLogSp, of type SP.

  2. Add a button to a form. Name the button TestSP and assign sTest as the caption.

    This button will be used to run the stored procedure.

  3. On the Components property sheet for the button, create an event named RunSp:
    1. Click Events (appears as a yellow lightning bolt on the component properties sheet).
    2. Click Primary, and then click the associated ellipses (...) button.
    3. In the Event Handlers dialog, click New.
    4. In the Event Handler Properties dialog, set these values:
      Event
      Specify RunSP.
      Description
      Enter an optional description or leave blank.
      Type
      Run Background Task.
    5. For the parameters, click Parms, and then click the ellipses (...) button. In the Event Handler Parms dialog, specify this information:
      Error Message
      Specify mBackendMessage.
      Success Message
      Specify sSubmitted.
    6. Click Type Specific Parameters. In the Edit Background Task Name and Parms dialog, specify this information:
      Task Name
      Specify AddProcessErrorLogSp.
      Task Parms
      Specify BG~TASKID~,FV(TestMessage).

      The FV keyword tells SyteLine to enclose the value of TestMessage in single quotes. The BG~TASKID~ substitution keyword is replaced at run time with the task number.

      For a complete list of keywords, see TaskMan substitution keywords.

    7. Click OK repeatedly until you return to the form.
    8. Verify that RunSP is the primary event for the TestSP button.
    9. Save the form.
  4. Add an Edit box to the form with a variable called TestMessage as the data source.
  5. Save the form.
  6. Enter a message in the TestMessage edit box, and submit the task.
    The system displays a message that says: Submitted.
  7. Open the Background Task History form. When the task completes, the test message displays in the event log.