sqlite function datetime() in tcl

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf sqlite function datetime() in tcl

  • Creator
    Topic
  • #52499
    Jeremy Bumgarner
    Participant

      I have a tcl script that inserts some values into a sqlite database table.  I have updated the table to have 2 new fields, both of which are datetime fields.

      table layout:

      Patient ID

      Lab Order

      Requester Order

      Order Date/Time

      Result Date/Time

      My old TCL statement to place the patient and order numbers into the table was this:

      set result [catch {DBCMD eval {INSERT INTO hms2allscriptsxlate VALUES ($PIDhmspat,$ORChmsorder,$ORCasorder) }}]

      I would like to use the SQLite function datetime() to populate the new fields.  I tried the following statement, but it did not work:

      set result [catch {DBCMD eval {INSERT INTO hms2allscriptsxlate VALUES ($PIDhmspat,$ORChmsorder,$ORCasorder, datetime(), null) }}]

      Do I need quotes around the SQLite function?  Or is there an equivalent TCL function?

    Viewing 2 reply threads
    • Author
      Replies
      • #74472
        Peter Heggie
        Participant

          I use this code to insert a date time:

          set sqlInsert “insert into audit (tstamp,msgid,srcmsgid,mrn,pan,location,loctype,type)”

          set sqlValues “select strftime(‘%Y-%m-%d %H:%M:%f’,’now’,’localtime’),’$mid’,’$srcmid’,’$mrn’,’$pan’,’$loc’,’$tloc’,’$type'”

          set sql “$sqlInsert $sqlValues”

          You could use something similar.

          Peter

          Peter Heggie
          PeterHeggie@crouse.org

        • #74473
          Jeremy Bumgarner
          Participant

            Very nice, thanks for the code.  And the quick response.

          • #74474
            Peter Heggie
            Participant

              Glad to help!

              Peter Heggie
              PeterHeggie@crouse.org

          Viewing 2 reply threads
          • The forum ‘Cloverleaf’ is closed to new topics and replies.