简体   繁体   中英

SSIS ForEach Loop Container only processing one row

I have a simple job that grabs Employee IDs and sends them to an API call, which only accepts one Employee ID at a time. I have this setup using a ForEach Loop Container being fed by an Execute SQL Task .

The job runs as expected, but it is only looping through the top N record.

My Execute SQL Task is returning a full result set to a variable. My variable is set as an Object data type. 执行 SQL 任务

执行 SQL 任务完整结果集变量

I have the ForEach Loop set to Foreach ADO Enumerator , then matched to my variable.

Foreach 循环编辑器

When I run the job I don't get a specific error message telling me what I'm doing wrong, but it fails at the ForEach Loop as shownForEachLoop

Anything else I can look out for?

The Execute SQL Task needs to shove results into an SSIS variable of Object type. I assume associateOID is a string type, yeah?

What you need to do is create an SSIS variable called something like rsEmployees of type Object. Your ResultSet in Execute SQL Task will then map to User::rsEmployees

Change the Foreach Loop ADO enumerator to use the variable User::rsEmployees

At this point, the package will execute and store the results into our rsEmployees variable and then the Foreach enumerator will iterate through the records in our set. The last piece is to do something with the current row. That's where your User::associateOID comes into play.

In the Variable Mappings tab of the Foreach Enumerator, add User::associateOID to ordinal 0. That will provide the linkage between the "current row" that is being shredded in the enumerator and our SSIS variables

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM