Page 1 of 1

Working with multi-member files using SQL

Posted: Mon Mar 23, 2009 1:18 pm
by Support_Julie
You can work with multi-member files using SQL in the following way –

Call a system procedure to override the default (*FIRST) member (just for this job)
Run the SQL Select statement in the usual way
Call another system procedure to reset the default member to what it was.

Below is an example:


/* Override to the member (the second parm must be the exact length of the string) */

CALL QSYS.QCMDEXC('OVRDBF FILE(file) TOFILE(library/file) MBR(member) OVRSCOPE(*JOB)', 0000000065.00000)


The number 0000000065.00000 is the length of the command in RED

/* Select records from the member */

SELECT * FROM file;

/* Delete the override to the member */

CALL QSYS.QCMDEXC('DLTOVR FILE(file) LVL(*JOB)', 0000000027.00000);


The number 0000000027.00000 is the length of the command in RED

In essence, you will have 3 Query Elements in your SQL Task, with the first query to override the default member name, the second to run the actual query and the third to delete the override.