Forum Discussion

rjapala's avatar
rjapala
New Contributor III
3 years ago

Pipeline expression building

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 !!

8 Replies

  • @rjapala You can use a combination of Sequence snap and Mapper snap, as shown below

    The expression used for the transformation is “P-%05d”.sprintf($value)

    • rjapala's avatar
      rjapala
      New Contributor III

      Like every time trigger the task then should generate the sequence and update the Product_ID

  • rjapala's avatar
    rjapala
    New Contributor III

    Thank you so much @Dheeraj

    I have a doubt here like how do we get each time a new sequence should i check with execute or validate

  • rjapala's avatar
    rjapala
    New Contributor III

    @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

    • Aleksandar_A's avatar
      Aleksandar_A
      Contributor III

      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.

      • rjapala's avatar
        rjapala
        New Contributor III

        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