Forum Discussion

del_exaclee's avatar
del_exaclee
New Contributor
7 years ago

ReadyAPI 2.5.0 - Parse jdbc response in Groovy script (until max row number value)

I am using a JDBC request in ReadyAPI 2.5.0 to retrieve data from our database. What I need to do is loop through all of the rows that are returned and pick out specific values for use in my SOAP request later on.

 

How do I use a Groovy script to take a JDBC response and loop through until all rows have been read? Please note the JDBC response will return a dynamic set of results each time so its important to loop until all rows have been processed.

 

I have included a sample JDBC response below for which we would need to extract values i.e. UNIQUEID and ROUTEID using a Groovy script and pass that into my SOAP request as a test case property.


<Results>
   <ResultSet fetchSize="128">
      <Row rowNumber="1">
         <UNIQUEID>80382049</UNIQUEID>
         <SOURCESYSTEM>HitsSC</SOURCESYSTEM>
         <ROUTEID>39812</ROUTEID>
         <SHIFTDATE>2018-12-07 00:00:00.0</SHIFTDATE>
      </Row>
      <Row rowNumber="2">
         <UNIQUEID>80382096</UNIQUEID>
         <SOURCESYSTEM>NTExchange</SOURCESYSTEM>
         <ROUTEID>39812</ROUTEID>
         <SHIFTDATE>2018-12-07 00:00:00.0</SHIFTDATE>
      </Row>
      <Row rowNumber="3">
         <UNIQUEID>80382097</UNIQUEID>
         <SOURCESYSTEM>NTExchange</SOURCESYSTEM>
         <ROUTEID>39812</ROUTEID>
         <SHIFTDATE>2018-12-07 00:00:00.0</SHIFTDATE>
      </Row>
      <Row rowNumber="4">
         <UNIQUEID>80382098</UNIQUEID>
         <SOURCESYSTEM>NTExchange</SOURCESYSTEM>
         <ROUTEID>39812</ROUTEID>
         <SHIFTDATE>2018-12-07 00:00:00.0</SHIFTDATE>
      </Row>
   </ResultSet>
</Results>

Regards,

Ajay