Hi sltfn,
Here is one way to format the results of a batchQuery into a line delimited list of tab delimited records. I tried to make it as generic as possible so other users can use it if they'd like.
A couple things to note:
- put flattenArray(tOutputA) into flattened will have to be changed to put flattenArray(tOutputA, "attributes,last_name,status,rank,city,year,name,date", "tab", true) into flattened.
- the code assumes that the batchQuery was only performed on one table. If this is not the case, you can pass another parameter after pBatchQueryA (pTableID) that will specify the table you are interested in. The outer repeat that uses xTableID will need to be removed and all references of xTableID will need to be changed to pTableID.
Hope this helps! Let me know if you have any questions.
Here is one way to format the results of a batchQuery into a line delimited list of tab delimited records. I tried to make it as generic as possible so other users can use it if they'd like.
Code:
function flattenArray pBatchQueryA, pKeys, pDelimiter, pIncludeRecordID
local tResults, tRecord
repeat for each key xTableID in pBatchQueryA
repeat for each key xIndex in pBatchQueryA[xTableID]
repeat for each key xRecordID in pBatchQueryA[xTableID][xIndex]
repeat for each item xKey in pKeys
put pBatchQueryA[xTableID][xIndex][xRecordID][xKey] & pDelimiter after tRecord
end repeat
if pIncludeRecordID then put xRecordID & pDelimiter after tRecord
delete char -1 of tRecord --remove trailing delimiter
put tRecord & lf after tResults
put empty into tRecord
end repeat
end repeat
end repeat
delete char -1 of tResults --remove trailing lf
return tResults
end flattenArray
A couple things to note:
- put flattenArray(tOutputA) into flattened will have to be changed to put flattenArray(tOutputA, "attributes,last_name,status,rank,city,year,name,date", "tab", true) into flattened.
- the code assumes that the batchQuery was only performed on one table. If this is not the case, you can pass another parameter after pBatchQueryA (pTableID) that will specify the table you are interested in. The outer repeat that uses xTableID will need to be removed and all references of xTableID will need to be changed to pTableID.
Hope this helps! Let me know if you have any questions.