|
669 | 669 | detail-map)) |
670 | 670 |
|
671 | 671 |
|
| 672 | +(defn run-statement |
| 673 | + [conn {:keys [stmt-text exec-mode op-comment binds opt-map commit?] :as stmt-detail-map}] |
| 674 | + |
| 675 | + """ |
| 676 | + Runs the statement represented by the supplied statement detail |
| 677 | + map. |
| 678 | +
|
| 679 | + Returns: The statement detail map updated with {:result result-data} |
| 680 | + """ |
| 681 | + |
| 682 | + (log/info (str "Running statement: [" stmt-text "] ...")) |
| 683 | + (let [sql-params (concat [stmt-text] binds)] |
| 684 | + (when op-comment |
| 685 | + (log/info (str "Operation comment: " op-comment))) |
| 686 | + (let [updated-map |
| 687 | + (assoc-in stmt-detail-map [:result] |
| 688 | + (cond |
| 689 | + (= exec-mode DB_EXEC_MODE_QUERY) |
| 690 | + (do |
| 691 | + (log/debug "Issuing statement as query (results expected) ...") |
| 692 | + (clojure.java.jdbc/query conn sql-params opt-map)) |
| 693 | + (= exec-mode DB_EXEC_MODE_EXEC) |
| 694 | + (do |
| 695 | + (log/debug "Issuing statement as execution (no results expected) ...") |
| 696 | + (clojure.java.jdbc/execute! conn sql-params opt-map))))] |
| 697 | + (when commit? |
| 698 | + (.commit (:connection conn))) |
| 699 | + updated-map))) |
| 700 | + |
| 701 | + |
672 | 702 | (defn run-sql-stmts-in-transaction |
673 | 703 | [conn-or-spec stmt-detail-vec] |
674 | 704 |
|
|
699 | 729 | (for [stmt-detail-map stmt-detail-vec] |
700 | 730 | (run-statement conn stmt-detail-map)))))) |
701 | 731 |
|
702 | | - |
703 | | -(defn run-statement |
704 | | - [conn {:keys [stmt-text exec-mode op-comment binds opt-map commit?] :as stmt-detail-map}] |
705 | | - |
706 | | - """ |
707 | | - Runs the statement represented by the supplied statement detail |
708 | | - map. |
709 | | -
|
710 | | - Returns: The statement detail map updated with {:result result-data} |
711 | | - """ |
712 | | - |
713 | | - (log/info (str "Running statement: [" stmt-text "] ...")) |
714 | | - (let [sql-params (concat [stmt-text] binds)] |
715 | | - (when op-comment |
716 | | - (log/info (str "Operation comment: " op-comment))) |
717 | | - (let [updated-map |
718 | | - (assoc-in stmt-detail-map [:result] |
719 | | - (cond |
720 | | - (= exec-mode DB_EXEC_MODE_QUERY) |
721 | | - (do |
722 | | - (log/debug "Issuing statement as query (results expected) ...") |
723 | | - (clojure.java.jdbc/query conn sql-params opt-map)) |
724 | | - (= exec-mode DB_EXEC_MODE_EXEC) |
725 | | - (do |
726 | | - (log/debug "Issuing statement as execution (no results expected) ...") |
727 | | - (clojure.java.jdbc/execute! conn sql-params opt-map))))] |
728 | | - (when commit? |
729 | | - (.commit (:connection conn))) |
730 | | - updated-map))) |
|
0 commit comments