Forum Discussion

MKV's avatar
6 years ago

How to iterate every row in JDBC resultset

Hi, With ReadyAPI, 2.2.0, I'm trying to validate my response data with the data in DB. There are cases where there could be multiple nodes with customer details. Number of customers will vary for e...
  • Radford's avatar
    6 years ago

    I always process XML data with the XmlSlurper. Here's some sample code of looping through some dummy JDBC test step data:


    import groovy.util.XmlSlurper
    def jdbcData = '''<Results>
        <ResultSet fetchSize="10">
            <Row rowNumber="1">
            <Row rowNumber="2">
            <Row rowNumber="3">
    def Results = new XmlSlurper().parseText(jdbcData)
    Results.ResultSet.Row.each(){Row ->


    As an alternative, without using Groovy, you could use an XML Data Source test step (taking its souce as the response of the JDBC test step), paired with a DataSource Loop Test Step will take care of all the looping functionality.