I am running a SQL query and returning objects as array in karate. I know how to read the first record/row returned. I need to know how to create a loop to read all the records, one at a time.
Here's the start where the SQL query is called and I am assigning objects to variables.
Scenario Outline: Premium-IC or IR Invoice Type
* def op_ic_ir_query = karate.readAsString('classpath:Payments/
CSC_Payments_API/Queries/qry_Get_Overpayment_IC_IR.txt')
* def OP1 = Stardb.readRows(op_ic_ir_query)
* def OP_cpid = OP1[0].CONTRACT_PAYMENT_ID
* def OP_cid = OP1[0].CONTRACT_ID
* def OP_iid = OP1[0].INVOICE_ID
* def OP_Idate = OP1[0].INVOICE_DATE
* def OP_dtp = OP1[0].DATE_TO_PROCESS
* def transactionAmt = OP1[0].TRANSACTION_AMOUNT
* def invoiceAmt = OP1[0].INVOICE_AMOUNT
* def taxAmt = OP1[0].TAX_AMOUNT
* def paidAmt = OP1[0].PAID_AMOUNT
The next step is calculating an overpayment amount.
# Calculate overpayment_amount - need to keep rolling total for
overpayment amount.
* def overpaymentAmt1 = (transactionAmt - ((invoiceAmt + taxAmt) -
paidAmt))