 
 
 
+(defn get-fields-for-table   [db-table]
+  [:id :item])
+
+
+(defn parse-int [s]
+   (Integer. (re-find  #"\d+" s )))
+
+
 
 ; ----------------------------------------------------------------
 ; Whenever a record changes an entry is added to the real time log

    (if (= (get realtime-log-entry :record_operation) "UPDATE")
      (do
        (println "Update record")
        (let [id               (get realtime-log-entry :record_id)
              db-table         (get realtime-log-entry :record_table_name)
              cached-record    (get-record-from-server-cache-for-id  db-table   id)
              ;record           (get-record-from-database    db-table id fields)
              ;table            (get-table-from-server-cache-for-table    db-table)
              ;query-time       (quot (System/currentTimeMillis) 1000)
              ]
          (create-cache-for-table   db-table)
          ;(if table
            ;(swap!  table assoc id (atom {:value record :timestamp query-time}))
            nil
          ;  )
        )
        ))

    ))


(defn get-record-from-database [db-table id fields]

  (let [sql (str
             "select " (fields-to-str fields) " from " db-table " where id = ? "
             (cond
              (= *database-type* "postgres" )
              " limit 1"

              (= *database-type* "oracle" )
              ""))
        ]
    (do
      (println "SQL::: " sql "," id)
      (sql-1  sql [id])
      )))



