We need to read a text file that has a record for each of the tables to be loaded.
The file can have comment lines, which begin with a #.
e.g.
Code: Select all
#Batch Code, Source File, Schema File, Target Table, Key Field(s)
#PRS tables
PRS,PRS-EMPLOYEE-*-EXTRACT.DAT,EmployeeFile.schema,EMPLOYEE,EMP_ID
#FIN tables
FIN,FIN-GLCODE-*-EXTRACT.DAT,GLCodeFile.schema,GLCODE,GLID
We're trying to use a Sequence to read the file using an Execute Command stage, and ignore any records starting with #. The command gets a list of Tables that we can loop through.
e.g. (I've bolded the part that ignores comment lines):
awk -v BatchCode="#PS_BatchCode#" -F, '!/^#/ && $1~BatchCode {print $4}' | paste -s -d, - | tr -d '\n'
Problem:
However, when trying to compile the Sequence, it complains that the parameter "/^# &&" is missing.
i.e. When the compiler reads the # symbol, it wants to do a parameter substitution.
Resolution:
Using \# did not work, so we created a parameter PS_HashSymbol with the value '#', and used that in the expression:
awk -v BatchCode="#PS_BatchCode#" -F, '!/^#PS_HashSymbol#/ && $1~BatchCode {print $4}' | paste -s -d, - | tr -d '\n'
But I'd prefer to use an escape character, rather than create another parameter.
Is there is an escape character that we can use, so that the Sequence compiler treats the # as a literal, not as a parameter identifier?