title: Optimize informix update
body: <p>I have a bash script that will update a table based on a file.  The way I have it it opens and closes for every line in the file and would like to understand how to open, perform all the updates, and then close. It is fine for a few updates but if it ever requires more than a few hundred could be really taxing on the system.</p>
  
  <pre><code>    #!/bin/bash
  
      file=/export/home/dncs/tmp/file.csv
      dateFormat=$(date +"%m-%d-%y-%T")
      LOGFILE=/export/home/dncs/tmp/Log_${dateFormat}.log
  
      echo "${dateFormat} : Starting work" &gt;&gt; $LOGFILE 2&gt;&amp;1
  
      while IFS="," read mac loc; do
        if [[ "$mac" =~ ^([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$ ]]; then
  
  
      dbaccess thedb &lt;&lt;EndOfUpdate &gt;&gt; $LOGFILE 2&gt;&amp;1
      UPDATE profile
      SET local_code= '$loc'
      WHERE mac_address = '$mac';
      EndOfUpdate
        else
      echo "Error: $mac not valid format" &gt;&gt; $LOGFILE 2&gt;&amp;1
      fi
      IIH -i $mac &gt;&gt; $LOGFILE 2&gt;&amp;1
  
  
      done &lt;"$file"
  </code></pre>
  
  <p>Source File.</p>
  
  <pre><code>12:BF:20:04:BB:30,POR-4
  12:BF:21:1C:02:B1,POR-10
  12:BF:20:04:72:FD,POR-4
  12:BF:20:01:5B:4F,POR-10
  12:BF:20:C2:71:42,POR-7
  </code></pre>