In many situations it is appropriate to try fixing error rows so that they can be applied to the destination table. Making these fixes typically involves modifying one or more of their column values so that the destination table will accept them. You can do this in a couple of different ways:
By letting the user edit one or more of the rows in the error DataWindow control (the easy way for you, because it does not require any coding work)
By executing script code in your application that edits one or more of the rows in the error DataWindow control for the user
In either case, the next step is to apply the modified rows from this DataWindow control to the destination table.
To apply row repairs to the destination table:
Code the Repair function in an appropriate script. In this function, specify the Transaction object for the destination database.
Test the result of the Repair function.
For more information on coding the Repair function, see the PowerScript Reference.
In the following example, users can edit the contents of the dw_pipe_errors DataWindow control to fix error rows that appear. They can then apply those modified rows to the destination table.
Providing a CommandButton When painting the w_sales_extract window, include a CommandButton control named cb_applyfixes. Then write code in a few of the application’s scripts to enable this CommandButton when dw_pipe_errors contains error rows and to disable it when no error rows appear.
Calling the Repair function Next write a script for the Clicked event of cb_applyfixes. This script calls the Repair function and tests whether or not it worked properly:
IF iuo_pipe_logistics.Repair(itrans_destination) &
<> 1 THEN
Beep (1)
MessageBox("Operation Status", "Error when &
trying to apply fixes.", Exclamation!)
END IF
Together, these features let a user of the application click the cb_applyfixes CommandButton to try updating the destination table with one or more corrected rows from dw_pipe_errors.
Earlier in this chapter you learned how to let users (or the application itself) stop writing rows to the destination table during the initial execution of a pipeline. If appropriate, you can use the same technique while row repairs are being applied.
For details, see “Canceling pipeline execution”.
The Repair function commits (or rolls back) database updates in the same way the Start function does.
For details, see “Committing updates to the database”.
Sometimes after the Repair function has executed, there may still be error rows left in the error DataWindow control. This may be because these rows:
Were modified by the user or application but still have errors
Were not modified by the user or application
Were never written to the destination table because the Cancel function was called (or were rolled back from the destination table following the cancellation)
At this point, the user or application can try again to modify these rows and then apply them to the destination table with the Repair function. There is also the alternative of abandoning one or more of these rows. You will learn about that technique next.