Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

How to force an Abort upon data condition check Expand / Collapse
Author
Message
Posted Wednesday, December 5, 2012 9:55 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Friday, March 21, 2014 2:32 PM
Points: 25, Visits: 178

What is the best way to make your SSIS Data Flow to fail upon a data condition check. What I'm doing is reading a flat file that has both detail records (counting this up) and a single trailer record (that has number of details records sent). If the two values do not match then fail. I'm at the point where I have the two values (total detail records, and trailer detail record count) to compare. I have a derived column ((DT_I8)DETAIL_REC_CNT == (DT_I8)[INT_SENT-REC-SNT] ? TRUE : FALSE
Upon the FALSE I want to Fail (stop the SSIS). I've only written a few SSIS's to date and have never dealt with ERROR path output. Is this how it's handled, and how?

Thank You
Post #1393099
Posted Thursday, December 6, 2012 6:34 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Today @ 7:22 PM
Points: 1,167, Visits: 1,207
bobd125 (12/5/2012)

What is the best way to make your SSIS Data Flow to fail upon a data condition check. What I'm doing is reading a flat file that has both detail records (counting this up) and a single trailer record (that has number of details records sent). If the two values do not match then fail. I'm at the point where I have the two values (total detail records, and trailer detail record count) to compare. I have a derived column ((DT_I8)DETAIL_REC_CNT == (DT_I8)[INT_SENT-REC-SNT] ? TRUE : FALSE
Upon the FALSE I want to Fail (stop the SSIS). I've only written a few SSIS's to date and have never dealt with ERROR path output. Is this how it's handled, and how?

It sounds to me like you want to use a Conditional Split transformation. If the counts match, then continue your processing other wise send to another branch where you can log the error (or do whatever else you may need). You wouldn't need the Derived column transformation (unless you need that True/False value somewhere farther down in your processing) using the conditional split.

http://www.bimonkey.com/2009/06/the-conditional-split-transformation/

HTH,
Rob
Post #1393479
Posted Thursday, December 6, 2012 6:59 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 7:35 AM
Points: 5,024, Visits: 11,754
robert.gerald.taylor (12/6/2012)
bobd125 (12/5/2012)

What is the best way to make your SSIS Data Flow to fail upon a data condition check. What I'm doing is reading a flat file that has both detail records (counting this up) and a single trailer record (that has number of details records sent). If the two values do not match then fail. I'm at the point where I have the two values (total detail records, and trailer detail record count) to compare. I have a derived column ((DT_I8)DETAIL_REC_CNT == (DT_I8)[INT_SENT-REC-SNT] ? TRUE : FALSE
Upon the FALSE I want to Fail (stop the SSIS). I've only written a few SSIS's to date and have never dealt with ERROR path output. Is this how it's handled, and how?

It sounds to me like you want to use a Conditional Split transformation. If the counts match, then continue your processing other wise send to another branch where you can log the error (or do whatever else you may need). You wouldn't need the Derived column transformation (unless you need that True/False value somewhere farther down in your processing) using the conditional split.

http://www.bimonkey.com/2009/06/the-conditional-split-transformation/

HTH,
Rob


What's ugly about all of this is that you have to read all of the rows & do a check before deciding whether to proceed.

A conditional split is part of your dataflow which (unless you have a clever solution I haven't thought of) would be checked for every input row & would therefore always fail - you don't reach the row containing the count until the very last row.

I'd be tempted to stage what's in the file (just the data rows, not the summary info), then compare the number of rows in this with what the trailer row says & then decide what to do next.



Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this link.

When you ask a question (and please do ask a question: "My T-SQL does not work" just doesn't cut it), please provide enough information for us to understand its context.
Post #1393497
Posted Thursday, December 6, 2012 10:32 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Friday, March 21, 2014 2:32 PM
Points: 25, Visits: 178
So ignore the Derived Column and just used "((DT_I8)DETAIL_REC_CNT == (DT_I8)[INT_SENT-REC-SNT] ? TRUE : FALSE " is the Conditional Split. And how do I set the Error Output, or default path?. I would like to have the DataFlow stop with an error.
Post #1393642
Posted Thursday, December 6, 2012 11:20 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 7:35 AM
Points: 5,024, Visits: 11,754
bobd125 (12/6/2012)
So ignore the Derived Column and just used "((DT_I8)DETAIL_REC_CNT == (DT_I8)[INT_SENT-REC-SNT] ? TRUE : FALSE " is the Conditional Split. And how do I set the Error Output, or default path?. I would like to have the DataFlow stop with an error.


As I alluded in my previous message, there is a fundamental problem with trying to do this all in a data flow. Data flow transformations occur for every row, as they pass through the pipeline.

How can you put a conditional split on row 1 of the data, when you do not yet know the total number of rows in the trailer?

Derived columns are similarly afflicted.

You need a way of reading all rows and doing the check before the rows go anywhere important. That is why I suggested an initial import to a staging table.



Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this link.

When you ask a question (and please do ask a question: "My T-SQL does not work" just doesn't cut it), please provide enough information for us to understand its context.
Post #1393661
Posted Friday, December 7, 2012 9:50 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Saturday, August 16, 2014 9:15 AM
Points: 2,818, Visits: 2,557
Phil is right on target. You have to deal with the entire file before you can evaluate the number of rows. Staging seems like the only solution to me.
Post #1394145
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse