Skip to content
Tcl Source Code History Of Ticket 93c1496269
Login

History Of Ticket 93c1496269

Artifacts Associated With Ticket 93c1496269

  1. Ticket change [4512ce1983] (rid 193361) by willbprog2762 on 2021-04-08 05:22:15:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/html"
    4. comment initialized to:
      <p>Running on Windows 10 Pro 64-bit Build 19042</p>
      
      <p>While writing a Tcl script to export MS Access tables to CSV files, I was using the <code>tdbc::odbc</code> package along with the system Access driver in 64-bit mode.</p>  
      
      <p>As mentioned in the documentation for <code>tdbc::resultset nextdict</code> (which <code>foreach</code> uses): <blockquote><em>"If a column's value in the row is NULL, its key is omitted from the dictionary."</em></blockquote>  Unfortunately I didn't see this detail until I had finished writing the bulk of my code.  Because the key and value both are missing from the resultset dictionary when the value is NULL, this leaves unwanted missing fields in the CSV output when using something like this (untested concept code):
      </p>
      
      <pre>
      set f [open "c:/users/will/desktop/table-dump.csv" "w"]
      
      $resultset foreach row {
        foreach {key value} $row {
          puts -nonewline $f "$key,"
          puts $f "$value"
        }
      }
      
      ...
      </pre>
      
      <p>
      I worked around this issue by using a <code>nextlist</code> with <code>while</code> and more complicated support code, but I feel this shouldn't have been necessary.  If the <code>$resultset foreach</code> had an <code>-emptystringsfornulls</code> (or some other better-named) option that would allow the key to remain in the dictionary, but with an empty string as a value, this would have allowed me to use my simple <code>$resultset foreach</code> code without outputing missing keys.
      
    5. foundin initialized to: "8.6.10"
    6. is_private initialized to: "0"
    7. login: "willbprog2762"
    8. priority initialized to: "5 Medium"
    9. private_contact initialized to: "937334650b1c1edd786dc48f2296354a1a36004a"
    10. resolution initialized to: "None"
    11. severity initialized to: "Minor"
    12. status initialized to: "Open"
    13. submitter initialized to: "willbprog2762"
    14. subsystem initialized to: "81. Bundled Packages"
    15. title initialized to:
      tdbc::odbc resultset foreach needs an option to allow empty values
      
    16. type initialized to: "RFE"