Neat trick of the day: Editing database files as if they were stream files

The background

Today I found and interface that works1 by copying a stream file into a database table and then attempting to parse the resulting mess. It’s been running for almost ten years and today it broke because some of the numbers in the stream file had decimal points in them2.

The interface in question is due to be retired shortly, so the program isn’t going to be fixed and the solution is to fix the data and then chase the folks that provided the stream file.

Have you ever tried to query or update a table that not only contains unstructured data but also has Carriage Return and Line Feed characters scattered throughout?

The solution

Work with Object Links is your friend.

This is the command you need:

WRKLNK '/QSYS.LIB/library.LIB/file.FILE/member.MBR'

The editing functionality is a bit basic, but it’s a lot easier than trying to database functionality to edit non-database data.

It’s also worth noting that the Work with Object Links actually knows what to do with Carriage Return and Line Feed characters.


1 In the loosest sense of the word.
2 Yes, really.