Roll back .AddRow() in Script Component?

  • Hi all

    I have an asynchronous script component which does something like this:

    try

    {

    this.DataOutputBuffer.AddRow();

    this.DataOutputBuffer.ETLLogPackageExecutionId = ETLLogPackageExecutionId;

    //other columns defined here

    }

    catch (Exception e)

    {

    //Unhandled data error encountered - write to the error table

    this.ErrorOutputBuffer.AddRow();

    this.ErrorOutputBuffer.Msg = e.Message;

    //other columns defined here

    }

    My intention is to write any rows to an error table if any of the column assignments fails. That works.

    Unfortunately, the (partially populated) row is also written to the destination table (DataOutputBuffer). This is what I want to prevent - if there's an error in the Try... section, I want to write it only to the error table.

    Any ideas?

    Many thanks.

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

  • Phil,

    I don't think you can prevent it once its been started. I think you have to do all the work to make sure that the values will be good or bad before you actually do the assignment. My experience has been that there are usually only a few rows that this might be a problem on.

    As a workaround, you could add a field like "RowCompleteFlag" and set the value to 0 right after you create the row and as the last step set it to 1, then right after or further down you could use a conditional split and just drop everything that isn't 1..

    CEWII

  • Elliott Whitlow (7/21/2013)


    Phil,

    I don't think you can prevent it once its been started. I think you have to do all the work to make sure that the values will be good or bad before you actually do the assignment. My experience has been that there are usually only a few rows that this might be a problem on.

    As a workaround, you could add a field like "RowCompleteFlag" and set the value to 0 right after you create the row and as the last step set it to 1, then right after or further down you could use a conditional split and just drop everything that isn't 1..

    CEWII

    Thank you Elliott - very nice idea with the workaround. I am doing some validation before the assignment, but it's difficult to catch everything, so I wanted a fail-safe mechanism to catch anything that slipped through the net.

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

  • Elliott - your workaround idea worked a treat, thanks again.

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

  • You are very welcome Phil, once you start dealing with the really custom sources or destinations it can get tricky really fast.

    CEWII

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply