Skip to content

Instantly share code, notes, and snippets.

@jhyland87
Created June 10, 2016 20:34
Show Gist options
  • Save jhyland87/de11d4c7d8f2cd22deed26f6501ec969 to your computer and use it in GitHub Desktop.
Save jhyland87/de11d4c7d8f2cd22deed26f6501ec969 to your computer and use it in GitHub Desktop.
# Construct query with first column as STOREID, and rest of the columns are inside an WHERE IN list
awk 'BEGIN{FS=",";OFS=",";}{gsub(/[[:blank:]]+/,","); storeid=$1; $1=""; print "UPDATE STOREITEM SET replenish_status = \"N\" WHERE COMPANYID = 1795 AND STOREID = "storeid" AND ITEMID IN ("substr($0, 2)");"}' file.csv
# Example Output Queries
# UPDATE STOREITEM SET replenish_status = 'N' WHERE COMPANYID = 1795 AND STOREID = 1749 AND ITEMID IN (118469,117677,118233,.....);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment