Written by

Sr Application Development Analyst at The Ohio State University Wexner Medical Center
Question Scott Roth · Nov 6

EnsLib.RecordMap.Service.FileService row?

When using a EnsLib.RecordMap.Service.FileService business service, is there a way to tell which row number that is being read in? I want to read in a csv, but on the first record, trigger a truncate on the External SQL Table that it is being written to through JDBC.

Thanks

Scott

Product version: IRIS 2025.1
$ZV: IRIS for UNIX (Red Hat Enterprise Linux 8 for x86-64) 2025.1 (Build 230_2U) Wed Jun 4 2025 18:50:44 EDT [HealthConnect:8.2.2]

Comments

Clayton Lewis · Nov 10

One way to do that would be to use EnsLib.RecordMap.Service.BatchFileService and configure it with BatchHandling = Whole Batch.

If you do that your Business Process will receive a Batch object that serves as parent to the individual Records in the file.  You can do the truncate, then loop over the records and process each one.

0
Scott Roth  Nov 10 to Clayton Lewis

Since the first line contains the column headers, I am using that to key off of.

0
Jeffrey Drumm  Nov 10 to Scott Roth

If you're using a custom business process to handle the message, you could perform the truncate in an OnRequest() callback.

If you're using a BPL, you would add an action near the beginning of the process to perform the truncate. The request object will be a single batch object containing a collection of records; the next step would be to iterate over the collection and perform the inserts.

You could do essentially the same thing in a DTL; use an SQL rule at the beginning to truncate, then add a foreach to iterate over the batch and populate the DB.

The key is the fact that your BP is getting all of the records in a single object. So when that object arrives, it's time to truncate the table and repopulate it. You will have to skip the first record if it contains headers, of course.

0