For a recent project I need to loop through rows of a csv (ignore.csv) with 3 columns:
acctnum, errcode, date
← in that order…
(Column naming doesn\
You're overwriting the file every time you echo inside the loop. Move the output redirection to the end of the loop.
while IFS=, read -r field1 field2 field3;
do
echo "UPDATE ODS.PERF_ACCT_ERR_DTL SET REC_ACTV_IND='T' WHERE BUS_DT='$field3' and ETL_ERR_CD='$field2' AND ACCT_KEY in (SELECT ACCT_KEY FROM ODS.ACCT_PORTFOLIO WHERE ACCT_SRCH_NBR='$field1');"
done < ignore.csv > sqlfile.txt