Forum Discussion

sravan's avatar
sravan
New Contributor II
3 years ago
Solved

Create statements based on the count

HI , We have a requirement where , we hit api and get the count. Based on the count we need to create some sql statements. for example if count is 500 we to create a statements like below select ...
  • bojanvelevski's avatar
    3 years ago

    Hi @sravan,

    You can use the following expression in a mapper in front of the SQL snap:

    sl.range(100,$count,100).map((x,ind) => "SELECT * FROM TABLE WHERE COLUMNCOUNT BETWEEN " + (ind == 0 ? 100 : x + 1) + " AND " + (ind == 0 ? 200 : (x+100 < $count ? x +100: $count)))

    Let me know if this helps,
    Regards,
    Bojan