SSIS 2008: Conditional logic to use different sources in Data Flow Task

409 views Asked by At

I have an SSIS 2008 package with data flow task using Task Factory Salesforce.com source, and in the WHERE clause is the below statement, which works fine.

WHERE SystemModstamp > <@User::dt_last_success>

I'd like to pull off a conditional 'IF @load_all_data=True THEN do not include the above WHERE clause, and if False then include it. I've been told that this is not possible in Salesforce Object Query Language (SOQL) to include that logic in the WHERE clause of the above query* , which means that I'll need two separate data sources: one with the current WHERE.., and one without.

I'd prefer not to copy-paste each data flow task, and the only different being the WHERE clause, to pull this off.

Question: What's the easiest way to pull off two sources based on logic with a parameter in a data flow task, using the same destination? Preferably without a JOIN that requires sorting.

Thanks in advance. Jim

1

There are 1 answers

0
billinkc On

I'm not familiar with the TaskFactory's Salesforce.com source, but most SSIS things allow for the concept of Expressions to be applied to them. Looking at the documentation for SFDC and knowing the PW folks, surely they allow for this.

Create a Variable, LoadAllData of type boolean and set it to False

Create a second variable, of type string, called Query. You will then need to set the EvaluateAsExpression property to True and then use an expression like the following (note the double quotes are part of the Expression.

"SELECT MyCols FROM MyTable "
+ (@[User::LoadAllData]) ? "" : "WHERE SystemModstamp > <@User::dt_last_success>"

That will build the query of SELECT MyCols FROM MyTable for the full load, SELECT MyCols FROM MyTable WHERE SystemModstamp > <@User::dt_last_success> for the incremental load.

Once you verify the strings are working, as expected with the variable toggle, you then go into your data flow, right click on the SFDC source and under Expressions, there ought to be something that corresponds to the SalesForceQuery and you then assign as its value @[User::Query]

Tying this all together, you'd then use the /SET property when you run the package to flip the value of LoadAllData to True whenever you need the full load (which I assume is the exception and not the standard case).

dtexec /file ./SFDC.dtsx /Set \Package.Variables[User::LoadAllData].Properties[Value];1

^^^ That's approximate. I haven't tried to set a boolean from the command line so it might expect True, true or possibly TRUE. Quick experimentation on your part should reveal the specific syntax.