Quantcast
Channel: SQL Server Integration Services forum
Viewing all articles
Browse latest Browse all 24688

Capturing values for import with incomplete rows (report-header style)

$
0
0

Greetings!  I am importing an Excel file which is formatted like a report - that is some columns are only populated once for each group of rows that it belongs to, such as:

CaseID  |Date       |Code
157207 |              |
            |8/1/2012 |64479
            |8/1/2012 |Q9967
            |8/1/2012 |99203

For the most part, I don't need these columns and use Conditional Splits to work my way to the detail rows.
However, there is one of these group headers (CaseID, in the example above) that I do need.
I have added a variable (User::CurrentCaseId) and a Script transform, with the following code:

public class ScriptMain : UserComponent
{
    string newCaseId;

    public override void Input0_ProcessInputRow(Input0Buffer Row)
    {
        if (!Row.CaseIDName_IsNull && Row.CaseIDName.Length > 0)
            newCaseId = Row.CaseIDName;
        else
            newCaseId = "DetailRow";
    }

    public override void PostExecute()
    {
        base.PostExecute();
            if (newClaimNumber != "DetailRow")
                Variables.CurrentCaseId = newCaseId;
    }

Basically, I am trying to read the the value when present and save it in this variable.
I then use a derived column to put the variable value into a new column.
Alas, the value is always blank (placed a data viewer after the derived column). 

I modified the script to always set the variable to a fixed string - the derived column is still blank.
This seemed like a good plan - any ideas where I went wrong?

Best,
Scott


Viewing all articles
Browse latest Browse all 24688

Trending Articles