Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

How to fetch multiple values from request and update to DB

mdsheeraz
mdsheeraz Posts: 25

Hi All,

We have a request with multiple sections which has different id's and username as below shown in the sample request.
Currently we are using JSON data bank to extract the values from id and username and in the next step using DB tool updating these values in to the DB table.

However, it is only fetching the first records from the request and updating in to the DB, could you please help how can we fetch all the records from request and update each records in to DB accordingly.

{
"records": [
{
"id": "rec25eKmUsfiieG2B",
"createdTime": "2021-05-21T20:17:43.000Z",
"username": "Jonny W"
},
{
"id": "rec2dLF92AG8JTL0S",
"createdTime": "2021-03-20T18:02:38.000Z",
"username": "Debbie"
},
{
"id": "rec5w5lUPzN8Yd3um",
"createdTime": "2021-03-20T20:41:51.000Z",
"username": "Louie"
}
]
}

Answers

  • williammccusker
    williammccusker Posts: 672 ✭✭✭

    Hi,

    You might need to look into this extension that can help split a message into each record and then uses a responder to process each record.

    https://docs.parasoft.com/display/SOAVIRT20241/Multiple+Response+Generator+1.1

  • mdsheeraz
    mdsheeraz Posts: 25

    Thank you so much William for your input, I tried to implement using Multiple response generator but it couldn't get the results as expected.

    In our scenario, we don't need to send any multiple response for each request in the list.
    From the below incoming request I need to fetch intervalDetails such as intervalDate, intervalStartTime,
    intervalEndTime and newValue and UPDATE those values in to the database table columns accordingly.

    {
    "digitalTwinRequest" : {
    "updateIntervalUsage" : {
    "env" : "qa",
    "meterNumber" : "DTM00003",
    "intervalDetails" : [
    {
    "intervalDate" : "2024-06-02",
    "intervalStartTime" : "10:00:00",
    "intervalEndTime" : "11:00:00",
    "newValue" : "10"
    },
    {
    "intervalDate" : "2024-06-02",
    "intervalStartTime" : "00:15:00",
    "intervalEndTime" : "02:30:00",
    "newValue" : "0.25"
    }
    ]
    }
    }
    }

  • williammccusker
    williammccusker Posts: 672 ✭✭✭

    Hi,

    The way the multiple response generator works is that it splits those "intervalDetails" items into just the single array item and forwards that to another responder. That second responder would then use data banks and tools on just the single array item to perform the actions needed. It could then return a result to the original responder for each item, or not. The client isn't sent multiple response.