0
votes

I'm using 2-D arraylist to store the query results of sql.rows in SOAP UI Groovy. Outputrows, in the below code, is an arraylist.

Outputrows = sql.rows("select CORR.Preferred as preferred ,CORR.Category as  category,CORR.Currency as currency\
                           from BENEFICIARY CORR \
                           JOIN LOCATION LOC  on CORR.UID=LOC.UID")

The problem with the arraylist is that I'm unable to update any value of a particular cell with the set command. Set is not a valid one for GroovyRowResult class.

Outputrows.get(row).set(col,categoryValue)

So I am just wondering if I can store the queryresults(Outputrows) to a 2D Map(Outputrows) and if so, how can I update the value of any particular row with the given map key.

[{'preferred': 'N', 'category': 'Commerical'}, {'currency': 'USD'}.. ] and so on. If I want to update Currency for the 3rd row, how can I update that.

Data in the output

Preferred | Category | Currency |
----------------------------------
    N     |   CMP     |   USD   |
---------------------------------- 
    Y     |   RTL     |   GBP   |
----------------------------------
    N     |   CMP     |   JPY   |
----------------------------------
    Y     |   RTL     |   USD   |
---------------------------------- 

Now here in 'outputrows' the values are stored from first row(N, CMP, USD) as Arraylist. I would like to store the values of the query result,'outputrows', as a Maps instead of Arraylist, so I can easily access any value in 'outputrows' with Map key.

Hope this makes sense.

1
May be you want to provide the actual data from query and how you want to build the expected data for next request? - Rao
So query results stored in 'Outputrows' should be copied to a 2D Map and then continue with that? - Y5288
if you show some sample data that would be good. - Rao
Updated my question with the sample data. Please check - Y5288

1 Answers

0
votes

I need to use the column name with put instead of the column number.

Outputrows.get(row).put("currency",categoryValue) .. this is correct

Outputrows.get(row).put(2,categoryValue).. adds a new column with name "2", instead of column reference to currency