Capturing SQL results into a data area Simon Hutchinson

​[[{“value”:”The idea for this post came from a Facebook thread. The question was: “Does anyone know of a way to insert the result of an SQL SELECT into a CL Variable? I can make an SQL select into a table and read (RCVF) the file of course… But can it be done in a more “direct” way?” One of the replies to the question piqued my interest.
Before I start showing examples of code I needed a SQL statement that anyone with a recent release of IBM i could execute in their partitions. I came up with retrieving the record length for the SYSDUMMY1 table. I find the easiest way to get that information is to use the SYSFILES SQL View.

01 SELECT MAXIMUM_RECORD_LENGTH
02 FROM QSYS2.SYSFILES
03 WHERE SYSTEM_TABLE_SCHEMA = ‘SYSIBM’
04 AND SYSTEM_TABLE_NAME = ‘SYSDUMMY1’

Read more »”}]] Read More 

Verified by MonsterInsights