fork download
  1. #! /usr/local/bin/gawk -f
  2.  
  3. /insert into/ {
  4. sub(/^ *insert into */,"")
  5. sub(/ .*/,"")
  6. print "insert into", $0, "(" }
  7.  
  8. /=>/ {
  9. sub(/^ */,""); sub(/ *[,)] *$/,"")
  10. split($0, fv, " *=> *")
  11. f[++n] = fv[1]; v[n] = fv[2] }
  12.  
  13. END {
  14. for (i=1; i<=n; i++)
  15. printf "%s%s\n", f[i],
  16. (i == n) ? ")" : ","
  17. print "values ("
  18. for (i=1; i<=n; i++)
  19. printf "%s%s\n", v[i],
  20. (i == n) ? ")" : "," }
Success #stdin #stdout 0s 5896KB
stdin
insert into tablename (
    field_1 => value_1,
    field_2 => value_2,
    field_3 => value_3)
stdout
insert into tablename (
field_1,
field_2,
field_3)
values (
value_1,
value_2,
value_3)