clx and mjf,
Note that $1 in a and the discussion in the referenced thread provide a test for exact matches, but $1 ~ /COMS|SMAS|MARC/ is testing for substring matches. In other words, if the first field in the input contains the substring COMS or the substring SMAS or the substring MARC , it will match even if it is not one of those three exact strings.
To get what was requested here, we would need something more like:
awk '
FNR == NR {
e = (FNR == 1) ? $1 : (e "|" $1)
next
}
$1 ~ e {if($1 in f)
print $1, $2, $3 >> f[$1]
else { f[$1] = "file_" $1
print $1, $2, $3 > f[$1]
}
close(f[$1])
}' client_list all_data.txt
Note that the close() is needed because since it is performing a substring match, even if there are only three lines in client_list , there could be thousands of output files created.
Of course, it is entirely possible that ROCK_PLSQL wants exact matches, but that is not what the code supplied in post #1 in this thread does.