To clarify let me give an example. I have a csv file that I have parsed the columns of but when I try to reference the field that contains date (formatted as 15-Jun-2020) my printf statement does not know how to escape it:
#Example csv content/placement (IGNORES.csv): C330001000,R3343,15-Jun-2020
while IFS=, read -r field1 field2 field3;
do
printf "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');\nCOMMIT;\n"
done < IGNORES.csv > queryfile.sql
The output ends up looking like this:
' and ETL_ERR_CD='R3343' AND ACCT_KEY in (SELECT ACCT_KEY FROM ODS.ACCT_PORTFOLIO WHERE ACCT_SRCH_NBR='C330001000');
COMMIT;
I tried some weird escape character combos I thought would help but so far the closest I've gotten is printing the whole thing but instead of it showing 15-Jun-2020 it shows field3 as the output. Any suggestions or references for understanding how to escape something stored within a variable?