Code: Select all
<project name="TEST SQL using QTEMP" mainModule="Main" version="1.0">
<module name="Main" logLevel="debug">
<timestamp>
<format outputVariable="cymd" pattern="yyyyMMdd" />
</timestamp>
<createFileList label="Count Files" numFilesFoundVariable="filesFound">
<fileset dir="/djohnson/outfile">
<wildcardFilter>
<include pattern="prefix_${cymd}_*" />
</wildcardFilter>
</fileset>
</createFileList>
<sql label="SQL" resourceId="Dev61">
<query label="create table">
<statement>create table qtemp.filecount (files NUM(3))</statement>
</query>
<query label="insert count value" whenNoDataFound="continue">
<statement>INSERT INTO qtemp.filecount(files) values(${filesFound} + 1)</statement>
</query>
<query label="Get File_Count" outputVariable="File_Count">
<statement>SELECT case
When files < 10 then '00'
When files < 100 then '0'
end
concat trim(char(files)) from qtemp.filecount</statement>
</query>
</sql>
<setVariable name="FileCount" value="${File_Count[1]}" />
<setVariable label="initialize file name" name="fileName" value="prefix_${cymd}_${FileCount}.zip" />
<copy label="Copy File" sourceFile="/source_path/filename"
destFile="/destination_path/${fileName}" whenFileExists="overwrite" />
</module>
</project>