Use Case: If we run a db select query and it has humungous data (more than 10MB) then it will fail as it has reached the limit. We can avoid such error using SQL with offset. In this use case, we will use a Stored procedure.
To know about Offset & Fetch:
https://soalicious.blogspot.com/2022/04/db-offset-fetch-clause.html
Highlevel steps:
- Create a db table orders.
- Create a offset select db query
- Wrap the sql query in a stored procedure.
- In the integration,
- 1st we take the total row count using db adaptet call
- Determine number of iteration - ceiling(totalRows / batch size)
- For each iteration,
- We will select the rows by offset
- For each row, we will log the row details
- Increment the counter and offset.
totalRows: number of rows fetched from db adapter.
batchSize: number(4.0)
totalIteration: ceiling(orajs29:divide($totalRows,$batchSize))
Counter: number(1)
fetchSize: $batchSize
offSet: number(0)
$Counter <=$totalIteration
concat("Order Details - OrderNr / Customer :",$currentRow/nsmpr3:Row/nsmpr3:Column[1]," / ",$currentRow/nsmpr3:Row/nsmpr3:Column[2])
Counter: $Counter + 1
offSet : $offSet + $fetchSize
No comments:
Post a Comment