โ03-07-2023 03:17 AM
Hi
In Database i have field called โProduct_IDโ i need to update the field with โP-00001โ when i execute the first time and Second time when i execute the field should be updated with โP-00002โ please give me an solution how to implement using which snap.
Thanks in Advance !!
โ03-07-2023 11:03 PM
@Dheeraj
I have a 10 rows in Database with field name โProduct_IDโ so in pipeline after getting the field i have to take last number like in โP-00010โ i have to take โ0โ and increment by 1 in pipeline and update back to the database like โP-00011โ .
Hope you got my point, Please give me solution
โ03-07-2023 11:58 PM
Hello @rjapala,
Try with the following expression in a Mapper Snap:
"P-%05d".sprintf(parseInt(parseInt($Product_ID.split("-")[1])+1))
Let me know if this helps you.
BR,
Aleksandar.
โ03-08-2023 03:33 AM
Thank you @AleksandarAngelevski for your reply
This is not working in realtime like i have created trigger task for my pipeline so whenever i hit from postman to the pipeline it should generate new Product id in database.
So iam confused how to solve can you please help me on this
โ03-11-2023 03:12 AM
Hi @rjapala,
Good day, hereโs an sql script that will update the product_id you can use the sql server execute snap to place the script
update yourtable
set product_id = format(convert(int, replace(isnull(product_id,'0'),'P-','')) + 1,'P-0000#')
Thanks,
EmEm