Problem solve Get help with specific problems with your technologies, process and projects.

Dynamic SQL statement in an RPG program

DB2/400 and DB2 UDB expert Kent Milligan discusses how to substring a character field on an SQL join statement.

In a dynamic SQL statement embedded in an RPG program, is it possible to substring a character field on a join statement? One of the join files has two fields -- one is numeric 3.0 and the other is numeric 4.0. Is it possible to join that file with one that has matching data in a 7-byte character field?
Yes, the SQL join criteria can contain expressions such as the following: SUBSTR(1,3,T1Col1)=T2Col

You could define an SQL view with this substring expression to simplify the SQL that's coded into your application.

Dig Deeper on RPG iSeries programming