05-08-2023 04:23 AM
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 * from table where columcount between 100 and 200
select * from table where columcount between 201 and 300
select * from table where columcount between 301 and 400
select * from table where columncount between 401 and 500
Every time the count should be incremented by 100 till the total count we got from api. please help! @bojanvelevski
Solved! Go to Solution.
05-08-2023 04:51 AM
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
05-08-2023 04:51 AM
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
05-09-2023 04:25 AM
@bojanvelevski it works. Thanks!