Canceling pipeline execution
In many cases you will want to provide users (or the application
itself) with the ability to stop execution of a pipeline while it
is in progress. For instance, you may want to give users a way out
if they start the pipeline by mistake or if execution is taking
longer than desired (maybe because many rows are involved).
To cancel pipeline execution:
-
Code the Cancel function
in an appropriate scriptMake sure that either the user or your application can execute
this function (if appropriate) once the pipeline has started. When Cancel is
executed, it stops the piping of any more rows after that moment.Rows that have already been piped up to that moment may or
may not be committed to the destination table, depending on the
Commit property you specified when building your Pipeline object
in the Data Pipeline painter. You will learn more about committing
in the next section. -
Test the result of the Cancel function
For more information on coding the Cancel function,
see the PowerScript Reference.
Example
The following example uses a command button to let users cancel
pipeline execution in the order entry application.
Providing a CommandButton
When creating the w_sales_extract window, include
a CommandButton control named cb_stop.
Then write code in a few of the application’s scripts to
enable this CommandButton when pipeline execution starts and to
disable it when the piping is done.
Calling the Cancel function
Next write a script for the Clicked event of cb_stop.
This script calls the Cancel function and tests
whether or not it worked properly:
1 |
IF iuo_pipe_logistics.Cancel() = 1 THEN |
1 |
   Beep (1) |
1 |
   MessageBox("Operation Status", & |
1 |
   "Piping stopped (by your request).") |
1 |
ELSE |
1 |
   Beep (1) |
1 |
   MessageBox("Operation Status", & |
1 |
   "Error when trying to stop piping.", & |
1 |
   Exclamation!) |
1 |
END IF |
Together, these features let a user of the application click
the cb_stop CommandButton to cancel
a pipeline that is currently executing.