Appending Recods in version 351

I have read a number of posts on this subject. None seem to touch on the problem at hand. I have created a flow that does the following. First I query (execSQL) a DB table based on an input value. This returns 0 - n rows. (works fine). Next I loop on the recordlist returned form the first DB call and execSQL for each row. This call returns 1 - n rows on each loop. What I’m trying to do is accumulate the records from this second record list. Each subsequent loop will produce 1 - n additional records to be appended. I have had no luck getting this to work. For each loop iteration I can get all records retrieved by the execSQL appended (basically by mapping the recordlist returned), but each supsequent loop overwrites the last loop’s appends.

invoke getFirsRecords
loop (in-array = firstRecords)
invoke getSecondRecords

From here I have tried everything I have read. For example:

invoke getFirsRecords
loop (in-array = firstRecords, out-array = secondRecords)
invoke getSecondRecords
map (results -> secondRecords)

This one returns the secondRecords retrieved on the last iteration only. I have tried appending here too, no luck.

I’ve tried:

invoke getFirsRecords
loop (in-array = firstRecords)
invoke getSecondRecords
loop (in-array = secondRecords)
map (secondRecord -> tempRecord)
map (tempRecord -> appendtoList -> allsecondRecords)
map (drop tempRecords)

This one returns only the last record retrieved, less information than the approach above.

I have spent quite a bit of time looking through posts here and elsewhere. I have tried various approaches based on posts and what seemed to make sense. No luck. I understand the difference between a reference and value copy. What doesn’t seem to be working is the append. If I step into this and watch the output, it looks like values are never appended but rather always inserted at the front of the allsecondsRecords. I am also wondering if these techniques work for our older version 3.5.1.

Any direction is appreciated.

OK, got this working. I was using appendToRecordList as a transformer. Once I invoked it separately, the append worked correctly