Repairing error rows

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:

In either case, the next step is to apply the modified rows from this DataWindow control to the destination table.

StepsTo apply row repairs to the destination table:

  1. Code the Repair function in an appropriate script. In this function, specify the Transaction object for the destination database.

  2. Test the result of the Repair function.

For more information on coding the Repair function, see the PowerScript Reference.

Example

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.

Canceling row repairs

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”.

Committing row repairs

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”.

Handling rows that still are not repaired

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:

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.