Forum Discussion

viji28's avatar
viji28
New Contributor
3 years ago

Array data into SQL script

Hello,

I have sample data which looks like this

The flow that I would like to achieve is, first I would like to dump the “Number” data in table1 , next I want to get the data number within the data array and put it in a SQL script, so that I can insert it in the DB. I have already tried the json splitter on the “data” array which does the job but I would like to avoid the splitter.
we have 1 document as input but when we split the lines, number of output would be more than 1. If we use a SQL script to achieve the same functionality , we can achieve 1 input 1 output.

Any help?

  • omiaye - Please download the attached ZIP file, decompress it, and import the SLP as a new pipeline.  

    The Sequence snap is pretty self-explanatory.  We're just getting the list of years we want records for.

    In the Mapper, we create both the Jan and Jul start/end dates as a document with and array containing two objects of start/end dates.

    Then we use JSON Splitter so each start/end date is a single document. 

    Finally, the Filter is used to prevent any future dates (i.e. when we're running in the first 6 months of the year.

    As with any solution, there are other ways to solve this, and I'm sure others in the Community can come up with a more concise way to do the same, but I wanted to give you an easily supported and understandable solution.

    Hope this helps!