How to load every 5th record into target table

How to load every 5th record into target table

We need to read the source table and load only 1st and every 5th (nth) records to target.

Let’s start the mapping for this. We need a sequence generator and a filter transformations to complete this requirement. The logic which we are following here is to assign sequence numbers from 1 t0 5 to source records using Sequence transformation and then Using a filter transformation to filter out all records other than first & 5th records.

Source – EMPLOYEES (Oracle Table)
Target – EMPLOYEES_TGT (Oracle Table)
Transformations

Sequence Generator – Assign sequence numbers from 1 to 5 using start, end value & cycle options.
Filter – To process only First & 5th record by filtering out all other records.

Complete Mapping with Sequence & Filter Transformations
Have a close look on the transformations and understand how we connected the ports.
Sequence Generator – See here how we assigned the attributes to assign numbers and limit to 5

Start Value – 1
Increment by – 1
End Value – 5
Current Value – 0
Enable ‘Cycle‘ & ‘Reset‘ Option

Filter – Give the filter condition to process only first & every 5th record.

NEXTVAL = 5 (Every Fifth Record)
NEXTVAL = 0 (First Record)
IIF(NEXTVAL=5 OR NEXTVAL=0,TRUE)

Session Statistics – 22 records out of 110 records got loaded to target.
Target Table – I have added the NEXTVAL also to target for easy understanding, We have only 1st and every 5th records in the target table.

Leave a comment

Your email address will not be published. Required fields are marked *